mirror of https://github.com/mgba-emu/mgba.git
GBA: Fix crash if a 512kb flash save is loaded when a game has a 1Mb flash override
This commit is contained in:
parent
ec529a86c7
commit
284f4df31b
1
CHANGES
1
CHANGES
|
@ -24,6 +24,7 @@ Bugfixes:
|
||||||
- VFS: Fix resource leaks if some allocations fail
|
- VFS: Fix resource leaks if some allocations fail
|
||||||
- Video: Fix an issue with very long filenames
|
- Video: Fix an issue with very long filenames
|
||||||
- GBA Video: Blended sprites should never have other effects applied
|
- 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:
|
Misc:
|
||||||
- Qt: Handle saving input settings better
|
- Qt: Handle saving input settings better
|
||||||
- Debugger: Free watchpoints in addition to breakpoints
|
- Debugger: Free watchpoints in addition to breakpoints
|
||||||
|
|
|
@ -149,14 +149,17 @@ void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming) {
|
||||||
GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata");
|
GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata");
|
||||||
return;
|
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;
|
off_t end;
|
||||||
if (!savedata->vf) {
|
if (!savedata->vf) {
|
||||||
end = 0;
|
end = 0;
|
||||||
savedata->data = anonymousMemoryMap(SIZE_CART_FLASH1M);
|
savedata->data = anonymousMemoryMap(SIZE_CART_FLASH1M);
|
||||||
} else {
|
} else {
|
||||||
end = savedata->vf->size(savedata->vf);
|
end = savedata->vf->size(savedata->vf);
|
||||||
if (end < SIZE_CART_FLASH512) {
|
if (end < flashSize) {
|
||||||
savedata->vf->truncate(savedata->vf, SIZE_CART_FLASH1M);
|
savedata->vf->truncate(savedata->vf, SIZE_CART_FLASH1M);
|
||||||
flashSize = SIZE_CART_FLASH1M;
|
flashSize = SIZE_CART_FLASH1M;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue