From 88212fc2deb72b3ab85313852b0b091edc88403b Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 1 Feb 2021 01:53:20 -0800 Subject: [PATCH] Core: Allow deserializing PNG savestates with ignoring extdata --- src/core/serialize.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/serialize.c b/src/core/serialize.c index f965418e5..446152e04 100644 --- a/src/core/serialize.c +++ b/src/core/serialize.c @@ -283,7 +283,11 @@ static void* _loadPNGState(struct mCore* core, struct VFile* vf, struct mStateEx success = success && PNGReadFooter(png, end); PNGReadClose(png, info, end); - if (success) { + if (!success) { + free(pixels); + mappedMemoryFree(state, stateSize); + return NULL; + } else if (extdata) { struct mStateExtdataItem item = { .size = width * height * 4, .data = pixels, @@ -292,8 +296,6 @@ static void* _loadPNGState(struct mCore* core, struct VFile* vf, struct mStateEx mStateExtdataPut(extdata, EXTDATA_SCREENSHOT, &item); } else { free(pixels); - mappedMemoryFree(state, stateSize); - return 0; } return state; }