From 6799b24730e2f3ded9ad3d5cebddab8f569454f7 Mon Sep 17 00:00:00 2001 From: Balint Kovacs Date: Mon, 29 Mar 2021 00:44:40 +0100 Subject: [PATCH] Fix a bug on 512B EEPROM saves Fixes #690 --- arm9/source/gamecart/card_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arm9/source/gamecart/card_spi.c b/arm9/source/gamecart/card_spi.c index f3ec65a..964d83b 100644 --- a/arm9/source/gamecart/card_spi.c +++ b/arm9/source/gamecart/card_spi.c @@ -307,7 +307,7 @@ int CardSPIReadSaveData_9bit(CardSPIType type, u32 pos, void* data, u32 size) { u32 read = 0; if (pos < 0x100) { - u32 len = 0x100 - pos; + u32 len = min(0x100 - pos, size); cmd[0] = SPI_512B_EEPROM_CMD_RDLO; cmd[1] = (u8) pos; @@ -318,7 +318,7 @@ int CardSPIReadSaveData_9bit(CardSPIType type, u32 pos, void* data, u32 size) { } if (end >= 0x100) { - u32 len = end - 0x100; + u32 len = min(end - 0x100, size); cmd[0] = SPI_512B_EEPROM_CMD_RDHI; cmd[1] = (u8)(pos + read);