GBA: Fix crash if a 512kb flash save is loaded when a game has a 1Mb flash override

This commit is contained in:
Jeffrey Pfau 2015-05-15 01:54:07 -07:00
parent ec529a86c7
commit 284f4df31b
2 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@ Bugfixes:
- 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

View File

@ -149,14 +149,17 @@ void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming) {
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;
}