Skip to content

Commit

Permalink
GB: Check for LY when loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Sep 12, 2016
1 parent 7b86d5c commit 740f7a0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gb/serialize.c
Expand Up @@ -88,6 +88,7 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
bool error = false;
int32_t check;
uint32_t ucheck;
int16_t check16;
LOAD_32LE(ucheck, 0, &state->versionMagic);
if (ucheck > GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION) {
mLOG(GB_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, ucheck);
Expand Down Expand Up @@ -125,6 +126,11 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
mLOG(GB_STATE, WARN, "Savestate is corrupted: video eventDiff is negative");
error = true;
}
LOAD_32LE(check16, 0, &state->video.ly);
if (check16 < 0 || check16 > GB_VIDEO_VERTICAL_TOTAL_PIXELS) {
mLOG(GB_STATE, WARN, "Savestate is corrupted: video y is out of range");
error = true;
}
if (error) {
return false;
}
Expand Down

0 comments on commit 740f7a0

Please sign in to comment.