GBA: Check for savestates made from differently sized ROMs
Jeffrey Pfau jeffrey@endrift.com
Tue, 02 Jun 2015 21:50:42 -0700
2 files changed,
5 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -36,6 +36,7 @@ - Qt: Fix maximum year in sensor override
- GBA: Cap audio FIFO read size during deserialization - GBA: Check for corrupted savestates when loading - GBA: Check for improperly sized savestates when loading + - GBA: Check for savestates made from differently sized ROMs Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M
src/gba/serialize.c
→
src/gba/serialize.c
@@ -90,6 +90,10 @@ if (state->timers[0].overflowInterval < 0 || state->timers[1].overflowInterval < 0 || state->timers[2].overflowInterval < 0 || state->timers[3].overflowInterval < 0) {
GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: overflowInterval is negative"); return; } + if (state->cpu.gprs[ARM_PC] == BASE_CART0 || (state->cpu.gprs[ARM_PC] & SIZE_CART0) >= gba->memory.romSize) { + GBALog(gba, GBA_LOG_WARN, "Savestate created using a differently sized version of the ROM"); + return; + } memcpy(gba->cpu->gprs, state->cpu.gprs, sizeof(gba->cpu->gprs)); gba->cpu->cpsr = state->cpu.cpsr; gba->cpu->spsr = state->cpu.spsr;