SpriteCB_EnemyShadow: Avoid use-after-free (#8220)

This commit is contained in:
Martin Griffin 2025-11-12 21:52:31 +00:00 committed by GitHub
parent fe85da81fc
commit 2bb0d0249d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1239,6 +1239,12 @@ void LoadAndCreateEnemyShadowSprites(void)
void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{
if (gBattleSpritesDataPtr == NULL)
{
shadowSprite->callback = SpriteCB_SetInvisible;
return;
}
bool8 invisible = FALSE;
u8 battler = shadowSprite->tBattlerId;
struct Sprite *battlerSprite = &gSprites[gBattlerSpriteIds[battler]];