From eb01bb8efb8dd56b8c09381ab469c2ecea554727 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 3 Jul 2019 13:01:10 -0700 Subject: [PATCH] GB: Fix savedata initialization (fixes #1473, fixes #1478) --- CHANGES | 1 + src/gb/gb.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 93085a05c..b21e247c0 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Emulation fixes: - GB Audio: Deschedule channel 3 when disabled (fixes mgba.io/i/1463) - GB Audio: Deschedule channel 1 when disabled by sweep (fixes mgba.io/i/1467) - GBA Memory: Fix STM/LDM to invalid VRAM + - GB: Fix savedata initialization (fixes mgba.io/i/1473, mgba.io/i/1478) Other fixes: - Switch: Fix threading-related crash on second launch - Qt: Fix FPS target maxing out at 59.727 (fixes mgba.io/i/1421) diff --git a/src/gb/gb.c b/src/gb/gb.c index 5f5178a90..3c2dfdad0 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -186,7 +186,7 @@ void GBResizeSram(struct GB* gb, size_t size) { vf->write(vf, extdataBuffer, vfSize & 0xFF); } gb->memory.sram = vf->map(vf, size, MAP_WRITE); - memset(&gb->memory.sram[gb->sramSize], 0xFF, size - gb->sramSize); + memset(&gb->memory.sram[vfSize], 0xFF, size - vfSize); } else if (size > gb->sramSize || !gb->memory.sram) { if (gb->memory.sram) { vf->unmap(vf, gb->memory.sram, gb->sramSize);