From 3a8ff86d6b5a940630f3cd5d041ab3d13413214f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 20 Feb 2019 19:44:11 -0800 Subject: [PATCH] GB: Fix crash when accessing SRAM if no save loaded and cartridge has no SRAM --- CHANGES | 1 + src/gb/gb.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index dfbc73d9b..db6a4acff 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ Bugfixes: - Switch: Fix gyroscope orientation (fixes mgba.io/i/1300) - GBA SIO: Prevent writing read-only multiplayer bits - 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: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash diff --git a/src/gb/gb.c b/src/gb/gb.c index 508483c1b..038401c83 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -202,7 +202,7 @@ void GBResizeSram(struct GB* gb, size_t size) { if (gb->memory.sram == (void*) -1) { gb->memory.sram = NULL; } - } else { + } else if (size) { uint8_t* newSram = anonymousMemoryMap(size); if (gb->memory.sram) { if (size > gb->sramSize) {