all repos — mgba @ ab028c9d80363fa61f2b7b77c22ad66f93303671

mGBA Game Boy Advance Emulator

GBA: Add more savestate checks
Jeffrey Pfau jeffrey@endrift.com
Wed, 03 Jun 2015 20:41:47 -0700
commit

ab028c9d80363fa61f2b7b77c22ad66f93303671

parent

3b29ba1aa29e9c303385b090aaaa6cc2733ad367

1 files changed, 8 insertions(+), 0 deletions(-)

jump to
M src/gba/serialize.csrc/gba/serialize.c

@@ -78,12 +78,20 @@ if (state->cpu.cycles < 0) {

GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are negative"); return; } + if (state->video.eventDiff < 0) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: video eventDiff is negative"); + return; + } if (state->video.nextHblank - state->video.eventDiff < 0) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: nextHblank is negative"); return; } 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->audio.eventDiff < 0) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: audio eventDiff is negative"); return; } if (state->audio.ch1.envelopeNextStep < 0 || state->audio.ch1.waveNextStep < 0 || state->audio.ch1.sweepNextStep < 0 || state->audio.ch1.nextEvent < 0) {