GB, GBA Savedata: Fix leaks when loading masked save (fixes #1197)
Vicki Pfau vi@endrift.com
Tue, 02 Oct 2018 08:19:47 -0700
5 files changed,
11 insertions(+),
7 deletions(-)
M
CHANGES
→
CHANGES
@@ -114,6 +114,7 @@ - Switch: Fix incorrect mapping for fast forward cap
- GB, GBA: Fix broken opposing button filter (fixes mgba.io/i/1191) - Qt: Fix jumbled background when paused - Qt: Fix FPS counter on Windows + - GB, GBA Savedata: Fix leaks when loading masked save (fixes mgba.io/i/1197) Misc: - mGUI: Add SGB border configuration option - mGUI: Add support for different settings types
M
src/gb/gb.c
→
src/gb/gb.c
@@ -249,7 +249,11 @@ }
} void GBSavedataMask(struct GB* gb, struct VFile* vf, bool writeback) { + struct VFile* oldVf = gb->sramVf; GBSramDeinit(gb); + if (oldVf && oldVf != gb->sramRealVf) { + oldVf->close(oldVf); + } gb->sramVf = vf; gb->sramMaskWriteback = writeback; gb->memory.sram = vf->map(vf, gb->sramSize, MAP_READ);
M
src/gba/gba.c
→
src/gba/gba.c
@@ -138,6 +138,8 @@ }
gba->memory.rom = NULL; gba->isPristine = false; + gba->memory.savedata.maskWriteback = false; + GBASavedataUnmask(&gba->memory.savedata); GBASavedataDeinit(&gba->memory.savedata); if (gba->memory.savedata.realVf) { gba->memory.savedata.realVf->close(gba->memory.savedata.realVf);
M
src/gba/memory.c
→
src/gba/memory.c
@@ -99,13 +99,6 @@ mappedMemoryFree(gba->memory.wram, SIZE_WORKING_RAM + SIZE_WORKING_IRAM);
if (gba->memory.rom) { mappedMemoryFree(gba->memory.rom, gba->memory.romSize); } - gba->memory.savedata.maskWriteback = false; - GBASavedataUnmask(&gba->memory.savedata); - GBASavedataDeinit(&gba->memory.savedata); - if (gba->memory.savedata.realVf) { - gba->memory.savedata.realVf->close(gba->memory.savedata.realVf); - } - if (gba->memory.agbPrintBuffer) { mappedMemoryFree(gba->memory.agbPrintBuffer, SIZE_AGB_PRINT); }
M
src/gba/savedata.c
→
src/gba/savedata.c
@@ -88,7 +88,11 @@ }
void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf, bool writeback) { enum SavedataType type = savedata->type; + struct VFile* oldVf = savedata->vf; GBASavedataDeinit(savedata); + if (oldVf && oldVf != savedata->realVf) { + oldVf->close(oldVf); + } savedata->vf = vf; savedata->mapMode = MAP_READ; savedata->maskWriteback = writeback;