GB Serialize: Prevent loading invalid states where LY >= 144 in modes other than 1

This commit is contained in:
Vicki Pfau 2024-07-19 19:42:38 -07:00
parent 7d8b029282
commit 00426ad6d1
2 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,7 @@ Emulation fixes:
Other fixes:
- 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

View File

@ -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");