all repos — mgba @ cd43d075617ad2d5172afd82213ee09f072d0f76

mGBA Game Boy Advance Emulator

GBA: Check for savestates made from differently sized ROMs
Jeffrey Pfau jeffrey@endrift.com
Tue, 02 Jun 2015 21:50:42 -0700
commit

cd43d075617ad2d5172afd82213ee09f072d0f76

parent

a51066820a4930fb3d63d410c8a1c7d2bce1ebac

2 files changed, 5 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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;