From 69c2969db01c900d000e9c7cdba83db0fd8036e2 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 15 Sep 2018 23:12:29 -0700 Subject: [PATCH] GB, GBA Savedata: Fix unmasking savedata crash --- CHANGES | 1 + src/gb/gb.c | 2 +- src/gba/savedata.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 8c59aa9e9..de550fef5 100644 --- a/CHANGES +++ b/CHANGES @@ -52,6 +52,7 @@ Bugfixes: - GBA Serialize: Fix loading states in Hblank - PSP2: Fix more issues causing poor audio - GBA Memory: Fix Vast Fame support (taizou) (fixes mgba.io/i/1170) + - GB, GBA Savedata: Fix unmasking savedata crash Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) diff --git a/src/gb/gb.c b/src/gb/gb.c index 3a812afa7..63d9f4b6d 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -256,7 +256,7 @@ void GBSavedataMask(struct GB* gb, struct VFile* vf, bool writeback) { } void GBSavedataUnmask(struct GB* gb) { - if (gb->sramVf == gb->sramRealVf) { + if (!gb->sramRealVf || gb->sramVf == gb->sramRealVf) { return; } struct VFile* vf = gb->sramVf; diff --git a/src/gba/savedata.c b/src/gba/savedata.c index bb19f3e34..9b637d914 100644 --- a/src/gba/savedata.c +++ b/src/gba/savedata.c @@ -95,7 +95,7 @@ void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf, bool writeb } void GBASavedataUnmask(struct GBASavedata* savedata) { - if (savedata->vf == savedata->realVf) { + if (!savedata->realVf || savedata->vf == savedata->realVf) { return; } enum SavedataType type = savedata->type;