Skip to content

Commit bf84dbf

Browse files
fix invalid array index crash in debug message (#6887)
1 parent b19c3e5 commit bf84dbf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

code/object/collideshipship.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,19 @@ int ship_ship_check_collision(collision_info_struct *ship_ship_hit_info)
389389
}
390390
if ((collide_obj != NULL) && (Ship_info[Ships[collide_obj->instance].ship_info_index].is_fighter_bomber())) {
391391
const char *submode_string = "";
392+
const char *mode_string = "";
392393
ai_info *aip;
393394

394395
extern const char *Mode_text[];
395396
aip = &Ai_info[Ships[collide_obj->instance].ai_index];
396397

398+
if (aip->mode >= 0)
399+
mode_string = Mode_text[aip->mode];
400+
397401
if (aip->mode == AIM_CHASE)
398402
submode_string = Submode_text[aip->submode];
399403

400-
nprintf(("AI", "Player collided with ship %s, AI mode = %s, submode = %s\n", Ships[collide_obj->instance].ship_name, Mode_text[aip->mode], submode_string));
404+
nprintf(("AI", "Player collided with ship %s, AI mode = %s, submode = %s\n", Ships[collide_obj->instance].ship_name, mode_string, submode_string));
401405
}
402406
#endif
403407
}

0 commit comments

Comments
 (0)