Fix UB in search_ground_1 in d_a_e_yg

This could cause a crash and was previously fixed by 7d3795f7, but
it's a band-aid solution. This fix addresses the underlying bug that
actually causes the crash.

The workaround remains in place for now because similar bugs related
to NaNs have been encountered, and it's not currently known how many
places in the codebase are affected as well.
This commit is contained in:
Max Roncace
2026-03-26 20:11:39 -04:00
parent 803eb07341
commit 6764a60364
+9 -1
View File
@@ -527,7 +527,7 @@ static void search_ground_1(e_yg_class* i_this) {
fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor;
dBgS_LinChk lin_chk;
cXyz start, end, work;
cXyz pos[16];
cXyz pos[16]{};
s16 y_rot = actor->shape_angle.y;
s8 line_cross_flag = false;
@@ -560,6 +560,14 @@ static void search_ground_1(e_yg_class* i_this) {
pos[i] = actor->current.pos;
pos[i].x += 10000.0f;
}
} else {
// Ensure all elements are initialized. This function is buggy and
// blows up if pos[0].x or pos[0].z is NaN, but for some reason this
// never happens on hardware - probably just dumb luck.
#if AVOID_UB
pos[i] = actor->current.pos;
pos[i].x += 10000.0f;
#endif
}
ANGLE_ADD(y_rot, 0x1000);