mirror of https://github.com/mgba-emu/mgba.git
GB: Check for LY when loading state
This commit is contained in:
parent
7b86d5cec7
commit
740f7a0f66
|
@ -88,6 +88,7 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
int32_t check;
|
int32_t check;
|
||||||
uint32_t ucheck;
|
uint32_t ucheck;
|
||||||
|
int16_t check16;
|
||||||
LOAD_32LE(ucheck, 0, &state->versionMagic);
|
LOAD_32LE(ucheck, 0, &state->versionMagic);
|
||||||
if (ucheck > GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION) {
|
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);
|
mLOG(GB_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, ucheck);
|
||||||
|
@ -125,6 +126,11 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
|
||||||
mLOG(GB_STATE, WARN, "Savestate is corrupted: video eventDiff is negative");
|
mLOG(GB_STATE, WARN, "Savestate is corrupted: video eventDiff is negative");
|
||||||
error = true;
|
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) {
|
if (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue