GB: Fix crash when accessing SRAM if no save loaded and cartridge has no SRAM

This commit is contained in:
Vicki Pfau 2019-02-20 19:44:11 -08:00
parent 0d178a4c3f
commit 5c42c5dcb7
2 changed files with 2 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Bugfixes:
- Switch: Fix gyroscope orientation (fixes mgba.io/i/1300) - Switch: Fix gyroscope orientation (fixes mgba.io/i/1300)
- GBA SIO: Prevent writing read-only multiplayer bits - GBA SIO: Prevent writing read-only multiplayer bits
- Qt: Fix color picking in sprite view (fixes mgba.io/i/1307) - Qt: Fix color picking in sprite view (fixes mgba.io/i/1307)
- GB: Fix crash when accessing SRAM if no save loaded and cartridge has no SRAM
Misc: Misc:
- GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1274) - GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1274)

View File

@ -202,7 +202,7 @@ void GBResizeSram(struct GB* gb, size_t size) {
if (gb->memory.sram == (void*) -1) { if (gb->memory.sram == (void*) -1) {
gb->memory.sram = NULL; gb->memory.sram = NULL;
} }
} else { } else if (size) {
uint8_t* newSram = anonymousMemoryMap(size); uint8_t* newSram = anonymousMemoryMap(size);
if (gb->memory.sram) { if (gb->memory.sram) {
if (size > gb->sramSize) { if (size > gb->sramSize) {