GBA: Check for savestates made from differently sized ROMs

This commit is contained in:
Jeffrey Pfau 2015-06-02 21:50:42 -07:00
parent a51066820a
commit cd43d07561
2 changed files with 5 additions and 0 deletions

View File

@ -36,6 +36,7 @@ Bugfixes:
- GBA: Cap audio FIFO read size during deserialization - GBA: Cap audio FIFO read size during deserialization
- GBA: Check for corrupted savestates when loading - GBA: Check for corrupted savestates when loading
- GBA: Check for improperly sized savestates when loading - GBA: Check for improperly sized savestates when loading
- GBA: Check for savestates made from differently sized ROMs
Misc: Misc:
- Qt: Handle saving input settings better - Qt: Handle saving input settings better
- Debugger: Free watchpoints in addition to breakpoints - Debugger: Free watchpoints in addition to breakpoints

View File

@ -90,6 +90,10 @@ void GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: overflowInterval is negative"); GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: overflowInterval is negative");
return; 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)); memcpy(gba->cpu->gprs, state->cpu.gprs, sizeof(gba->cpu->gprs));
gba->cpu->cpsr = state->cpu.cpsr; gba->cpu->cpsr = state->cpu.cpsr;
gba->cpu->spsr = state->cpu.spsr; gba->cpu->spsr = state->cpu.spsr;