Merge pull request #2124 from cawtds/fix-active-battler-ub

ub fix for OOB access with gActiveBattler
This commit is contained in:
GriffinR 2026-01-03 14:26:03 -05:00 committed by GitHub
commit b4abc6b5ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,11 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
gBattleControllerExecFlags = 0;
ClearBattleAnimationVars();
ClearBattleMonForms();
// UB: at the start of a battle CheckMoveLimitations is called with gActiveBattler
// from the previous battle, which can lead to multiple arrays being accessed out of bounds
#ifdef UBFIX
gActiveBattler = 0;
#endif
BattleAI_HandleItemUseBeforeAISetup(0xF);
if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE)