From 7b86d5cec770712915edbcd7bf1b0ad96d1938dd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 12 Sep 2016 12:38:16 -0700 Subject: [PATCH] GB Serialize: Prevent loading savestates that aren't about to load an instruction --- src/gb/serialize.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gb/serialize.c b/src/gb/serialize.c index f8b462752..145296161 100644 --- a/src/gb/serialize.c +++ b/src/gb/serialize.c @@ -112,6 +112,10 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) { mLOG(GB_STATE, WARN, "Savestate is corrupted: CPU cycles are negative"); error = true; } + if (state->cpu.executionState != LR35902_CORE_FETCH) { + mLOG(GB_STATE, WARN, "Savestate is corrupted: Execution state is not FETCH"); + error = true; + } if (check >= (int32_t) DMG_LR35902_FREQUENCY) { mLOG(GB_STATE, WARN, "Savestate is corrupted: CPU cycles are too high"); error = true;