From 42b011a68ba30aa5720ef6601efc72e256a2de9a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 5 Oct 2015 19:24:06 -0700 Subject: [PATCH] GBA: Check for cycle count being too high --- CHANGES | 1 + src/gba/serialize.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 8f530d6de..a56b0a3be 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,7 @@ Misc: - Qt: Dropping multiplayer windows works more cleanly now - GBA BIOS: Implement RegisterRamReset for SIO registers - GBA: Additional savestate sanity checks + - GBA: Check for cycle count being too high 0.3.0: (2015-08-16) Features: diff --git a/src/gba/serialize.c b/src/gba/serialize.c index c9f4b21b5..ae20f3613 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -87,6 +87,10 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are negative"); error = true; } + if (state->cpu.cycles >= (int32_t) GBA_ARM7TDMI_FREQUENCY) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are too high"); + error = true; + } if (state->cpu.nextEvent < 0) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: Next event is negative"); error = true;