Skip to content

Commit

Permalink
GB Serialize: Prevent loading invalid states where LY >= 144 in modes…
Browse files Browse the repository at this point in the history
… other than 1
  • Loading branch information
endrift committed Jul 20, 2024
1 parent eb1b571 commit 09f4564
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Other fixes:
- Debugger: Fix writing to specific segment in command-line debugger
- GB: Fix uninitialized save data when loading undersized temporary saves
- GB, GBA Core: Fix memory leak if reloading debug symbols
- GB Serialize: Prevent loading invalid states where LY >= 144 in modes other than 1
- GBA Audio: Fix crash if audio FIFOs and timers get out of sync
- GBA Audio: Fix crash in audio subsampling if timing lockstep breaks
- GBA Core: Fix loading symbols from ELF files if the file doesn't end with .elf
Expand Down
7 changes: 7 additions & 0 deletions src/gb/serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
mLOG(GB_STATE, WARN, "Savestate is corrupted: video y is out of range");
error = true;
}

GBSerializedVideoFlags videoFlags = state->video.flags;
if (check16 >= GB_VIDEO_VERTICAL_PIXELS && GBSerializedVideoFlagsGetMode(videoFlags) != 1) {
mLOG(GB_STATE, WARN, "Savestate is corrupted: video y is in vblank but mode is not vblank");
error = true;
}

LOAD_16LE(ucheck16, 0, &state->memory.dmaDest);
if (ucheck16 + state->memory.dmaRemaining > GB_SIZE_OAM) {
mLOG(GB_STATE, WARN, "Savestate is corrupted: DMA destination is out of range");
Expand Down

0 comments on commit 09f4564

Please sign in to comment.