From aa611dbbc0af4621b2de549294a7c8310484bb53 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 21 Apr 2017 16:22:48 -0700 Subject: [PATCH] Core: Fix crash with rewind if savestates shrink --- CHANGES | 1 + src/core/rewind.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 154475c82..ff6f25ddd 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugfixes: - GBA BIOS: Fix ArcTan sign in HLE BIOS - GBA BIOS: Fix ArcTan2 sign in HLE BIOS (fixes mgba.io/i/689) - GBA Video: Don't update background scanline params in mode 0 (fixes mgba.io/i/377) + - Core: Fix crash with rewind if savestates shrink Misc: - Qt: Improved HiDPI support - Feature: Support ImageMagick 7 diff --git a/src/core/rewind.c b/src/core/rewind.c index e48b2eb8b..ab4fe3cd7 100644 --- a/src/core/rewind.c +++ b/src/core/rewind.c @@ -48,6 +48,8 @@ void mCoreRewindAppend(struct mCoreRewindContext* context, struct mCore* core) { if (size2 > size) { context->currentState->truncate(context->currentState, size2); size = size2; + } else if (size > size2) { + nextState->truncate(nextState, size); } void* current = context->currentState->map(context->currentState, size, MAP_READ); void* next = nextState->map(nextState, size, MAP_READ);