From 853cdf28803caa5ad9ba0f3decf47522739e8b04 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 18 Jun 2020 01:25:48 -0700 Subject: [PATCH] GB Core: Fix extracting SRAM when none is present --- CHANGES | 2 ++ src/gb/core.c | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 8075b84e7..2b30c383f 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ Emulation fixes: - GB Memory: Fix OAM DMA from top 8 kB - GB MBC: Fix MBC1 RAM enable bit selection - GB MBC: Fix MBC2 bit selection +Other fixes: + - GB Core: Fix extracting SRAM when none is present 0.8.2: (2020-06-14) Emulation fixes: diff --git a/src/gb/core.c b/src/gb/core.c index 11d3f11ed..6fa39c203 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -822,9 +822,13 @@ static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) { vf->seek(vf, 0, SEEK_SET); return vf->read(vf, *sram, vf->size(vf)); } - *sram = malloc(gb->sramSize); - memcpy(*sram, gb->memory.sram, gb->sramSize); - return gb->sramSize; + if (gb->sramSize) { + *sram = malloc(gb->sramSize); + memcpy(*sram, gb->memory.sram, gb->sramSize); + return gb->sramSize; + } + *sram = NULL; + return 0; } static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {