Skip to content

Commit

Permalink
[Critical] fix memory corruption when handling trigger sprites (#3238)
Browse files Browse the repository at this point in the history
Co-authored-by: sbird <[email protected]>
  • Loading branch information
SBird1337 and sbird authored Aug 17, 2023
1 parent dba28cf commit cd90fde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,11 +1409,10 @@ bool32 IsMegaTriggerSpriteActive(void)

void HideMegaTriggerSprite(void)
{
if (gBattleStruct->mega.triggerSpriteId != 0xFF)
{
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, 0);
gSprites[gBattleStruct->mega.triggerSpriteId].tHide = TRUE;
}
if (gBattleStruct->mega.triggerSpriteId >= MAX_SPRITES)
return;
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, 0);
gSprites[gBattleStruct->mega.triggerSpriteId].tHide = TRUE;
}

void HideTriggerSprites(void)
Expand Down
7 changes: 5 additions & 2 deletions src/battle_z_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,12 @@ bool32 IsZMoveTriggerSpriteActive(void)

void HideZMoveTriggerSprite(void)
{
struct Sprite *sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId];
sprite->tHide = TRUE;
struct Sprite *sprite;
gBattleStruct->zmove.viable = FALSE;
if (gBattleStruct->zmove.triggerSpriteId >= MAX_SPRITES)
return;
sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId];
sprite->tHide = TRUE;
}

static void ShowZMoveTriggerSprite(u8 battlerId)
Expand Down

0 comments on commit cd90fde

Please sign in to comment.