fix UB in zoness

This commit is contained in:
Sonic Dreamcaster 2024-11-19 00:09:47 -03:00
parent c1fa820bfc
commit 45c334c585

View File

@ -3316,7 +3316,7 @@ void Zoness_801989FC(ZoSarumarine* this) {
} }
void Zoness_80198BE8(ZoSarumarine* this, s32 arg1) { void Zoness_80198BE8(ZoSarumarine* this, s32 arg1) {
s32 var_s1; s32 i;
Effect398* effect398; Effect398* effect398;
Vec3f src = { 0.0f, 0.0f, 100.0f }; Vec3f src = { 0.0f, 0.0f, 100.0f };
Vec3f dest; Vec3f dest;
@ -3335,7 +3335,7 @@ void Zoness_80198BE8(ZoSarumarine* this, s32 arg1) {
} }
} }
for (var_s1 = 0, effect398 = &gEffects[0]; var_s1 < 100; var_s1++, effect398++) { for (i = 0, effect398 = &gEffects[0]; i < ARRAY_COUNT(gEffects); i++, effect398++) {
if (effect398->obj.status == OBJ_FREE) { if (effect398->obj.status == OBJ_FREE) {
Effect_Initialize(effect398); Effect_Initialize(effect398);
effect398->obj.status = OBJ_INIT; effect398->obj.status = OBJ_INIT;
@ -3360,9 +3360,11 @@ void Zoness_80198BE8(ZoSarumarine* this, s32 arg1) {
break; break;
} }
} }
if (var_s1 >= ARRAY_COUNT(gActors)) { #ifndef AVOID_UB
if (i >= ARRAY_COUNT(gActors)) {
effect398->obj.status = OBJ_FREE; effect398->obj.status = OBJ_FREE;
} }
#endif
} }
} }