Core: Don't attempt to restore rewind diffs past start of rewind

This commit is contained in:
Vicki Pfau 2021-06-17 00:20:29 -07:00
parent d1ce973756
commit 3f4d2f6086
2 changed files with 14 additions and 11 deletions

View File

@ -18,6 +18,7 @@ Other fixes:
- Core: Fix memory leak in opening games from the library
- Core: Fix memory searches for relative values (fixes mgba.io/i/2135)
- Core: Fix portable mode on macOS
- Core: Don't attempt to restore rewind diffs past start of rewind
- GB Core: Fix GBC colors setting breaking default model overrides (fixes mgba.io/i/2161)
- GBA: Fix out of bounds ROM accesses on patched ROMs smaller than 32 MiB
- Qt: Fix infrequent deadlock when using sync to video

View File

@ -12,7 +12,7 @@
DEFINE_VECTOR(mCoreRewindPatches, struct PatchFast);
void _rewindDiff(struct mCoreRewindContext* context);
static void _rewindDiff(struct mCoreRewindContext* context);
#ifndef DISABLE_THREADING
THREAD_ENTRY _rewindThread(void* context);
@ -136,6 +136,7 @@ bool mCoreRewindRestore(struct mCoreRewindContext* context, struct mCore* core)
}
--context->current;
if (context->size) {
struct PatchFast* patch = mCoreRewindPatchesGetPointer(&context->patchMemory, context->current);
size_t size2 = context->previousState->size(context->previousState);
size_t size = context->currentState->size(context->currentState);
@ -147,6 +148,7 @@ bool mCoreRewindRestore(struct mCoreRewindContext* context, struct mCore* core)
patch->d.applyPatch(&patch->d, previous, size, current, size);
context->currentState->unmap(context->currentState, current, size);
context->previousState->unmap(context->previousState, previous, size);
}
struct VFile* nextState = context->previousState;
context->previousState = context->currentState;
context->currentState = nextState;