From 6a65d8d5326049a6d4cbe1998603dde6052392ba Mon Sep 17 00:00:00 2001 From: AreaZeroArven <122058867+AreaZeroArven@users.noreply.github.com> Date: Fri, 6 Jan 2023 11:19:13 -0500 Subject: [PATCH] battle-anim:fix UB by subtracting by 16 The current code follows the nonsensical asm generated by agbcc, which converted a subtraction by 16 into an addition by a halfword value of -16. This conversion happened at the portion of the compiler that does platform-specific transformations. This code in C is UB, as it relies on overflowing of a negative value. Signed-off-by:Arven --- src/battle_anim_fight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_anim_fight.c b/src/battle_anim_fight.c index 764a951ef8..cbefb41f1e 100644 --- a/src/battle_anim_fight.c +++ b/src/battle_anim_fight.c @@ -493,7 +493,7 @@ static void AnimFistOrFootRandomPos(struct Sprite *sprite) y *= -1; if (GET_BATTLER_SIDE2(battler) == B_SIDE_PLAYER) - y += 0xFFF0; + y -= 16; sprite->x += x; sprite->y += y;