From af6164e353006c900f809734c69eeb68e4d04380 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Sun, 17 Nov 2024 15:32:41 -0300 Subject: [PATCH] UB fix in Bolse's Event Handler update function --- src/overlays/ovl_i4/fox_bo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/overlays/ovl_i4/fox_bo.c b/src/overlays/ovl_i4/fox_bo.c index dcfd947d..40f860d3 100644 --- a/src/overlays/ovl_i4/fox_bo.c +++ b/src/overlays/ovl_i4/fox_bo.c @@ -203,7 +203,7 @@ void Bolse_SpawnEnemies(ActorEvent* this, s32 count) { } void Bolse_UpdateEventHandler(ActorEvent* this) { - s32 i; + s32 i = 0; Player* player = &gPlayer[0]; s32 pad; Actor* actor; @@ -352,7 +352,12 @@ void Bolse_UpdateEventHandler(ActorEvent* this) { case 10: if (gBosses[1].obj.status != 0) { if (fabsf(Math_SmoothStepToF(&gBosses[1].scale, 0.0f, 1.0f, 0.05f, 0.001f)) < 0.05f) { +// @bug: i is uninitialized and likely contains stack garbage. +#ifdef AVOID_UB + Object_Kill(&gBosses[1].obj, gBosses[1].sfxSource); +#else Object_Kill(&gBosses[1].obj, gBosses[i].sfxSource); +#endif gLight1R = 100; gLight1G = 100; gLight1B = 80;