From 5cfab59209b695c3eb3f0bc5f77adbd745b190f0 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Fri, 4 Jul 2025 18:11:32 +0200 Subject: [PATCH] Fix OOB in Cmd_selectfirstvalidtarget (#7269) --- src/battle_script_commands.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 10c81993e8..25edc5d759 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14530,6 +14530,8 @@ static void Cmd_selectfirstvalidtarget(void) if (IsBattlerAlive(gBattlerTarget)) break; } + if (gBattlerTarget >= gBattlersCount) + gBattlerTarget = 0; gBattlescriptCurrInstr = cmd->nextInstr; }