all repos — mgba @ 284f4df31ba30f917d717485505d73f7465a9209

mGBA Game Boy Advance Emulator

GBA: Fix crash if a 512kb flash save is loaded when a game has a 1Mb flash override
Jeffrey Pfau jeffrey@endrift.com
Fri, 15 May 2015 01:54:07 -0700
commit

284f4df31ba30f917d717485505d73f7465a9209

parent

ec529a86c795b46f08d92f20cffed3920ce7b3c8

2 files changed, 6 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -24,6 +24,7 @@ - GBA Memory: Improve Thumb open bus behavior

- VFS: Fix resource leaks if some allocations fail - Video: Fix an issue with very long filenames - GBA Video: Blended sprites should never have other effects applied + - GBA: Fix crash if a 512kb flash save is loaded when a game has a 1Mb flash override Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/gba/savedata.csrc/gba/savedata.c

@@ -149,14 +149,17 @@ if (savedata->type != SAVEDATA_FLASH512 && savedata->type != SAVEDATA_FLASH1M) {

GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata"); return; } - size_t flashSize = SIZE_CART_FLASH512; + int32_t flashSize = SIZE_CART_FLASH512; + if (savedata->type == SAVEDATA_FLASH1M) { + flashSize = SIZE_CART_FLASH1M; + } off_t end; if (!savedata->vf) { end = 0; savedata->data = anonymousMemoryMap(SIZE_CART_FLASH1M); } else { end = savedata->vf->size(savedata->vf); - if (end < SIZE_CART_FLASH512) { + if (end < flashSize) { savedata->vf->truncate(savedata->vf, SIZE_CART_FLASH1M); flashSize = SIZE_CART_FLASH1M; }