Skip to content

Commit

Permalink
Fix UB in Sector Z
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicdcer committed Jan 7, 2025
1 parent 57e3993 commit c569de7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/overlays/ovl_i4/fox_sz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,9 @@ void SectorZ_LoadLevelObjects(void) {
}
}

//! @bug: aSzLevelObjects has 12 actors, loading from gActors[50] to gActors[59] only account for 10 of them.
//! @bug: aSzLevelObjects has 12 actors, loading from gActors[50] to gActors[59] only accounts for 10 of them.
#ifdef AVOID_UB
for (j = 48, actor = &gActors[j], i = 0; i < 1000; i++) {
for (j = 47, actor = &gActors[j], i = 0; i < 1000; i++) {
#else
for (j = 50, actor = &gActors[j], i = 0; i < 1000; i++) {
#endif
Expand All @@ -1896,8 +1896,11 @@ void SectorZ_LoadLevelObjects(void) {
actor->rot_0F4.y = RAND_FLOAT_CENTERED(4.0f);
Object_SetInfo(&actor->info, actor->obj.id);
actor->itemDrop = DROP_SILVER_RING;

#ifdef AVOID_UB
if (j++ >= ARRAY_COUNT(gActors) - 1) {
#else
if (j++ >= ARRAY_COUNT(gActors)) {
#endif
break;
}
actor++;
Expand Down

0 comments on commit c569de7

Please sign in to comment.