UBFIX: sprite.c (#1442)

Fix out-of-bounds array access in `SortSprites()`.

Co-authored-by: Marcus Huderle <huderlem@gmail.com>
This commit is contained in:
gAlfonso-bit 2021-05-23 10:10:55 -04:00 committed by GitHub
parent ef6d91b0e3
commit a454f9c187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -452,6 +452,10 @@ void SortSprites(void)
// Although this doesn't result in a bug in the ROM,
// the behavior is undefined.
j--;
#ifdef UBFIX
if (j == 0)
break;
#endif
sprite1 = &gSprites[sSpriteOrder[j - 1]];
sprite2 = &gSprites[sSpriteOrder[j]];
@ -661,8 +665,7 @@ void ResetOamRange(u8 a, u8 b)
for (i = a; i < b; i++)
{
struct OamData *oamBuffer = gMain.oamBuffer;
oamBuffer[i] = *(struct OamData *)&gDummyOamData;
gMain.oamBuffer[i] = *(struct OamData *)&gDummyOamData;
}
}