Skip to content

Commit 6cf6b32

Browse files
committed
patch some crash vulnerabilities in hud_target_live_turret
These checks risked causing a crash or memory access violation if they were ever encountered with an invalid target when `auto_advance` is true.
1 parent f464b30 commit 6cf6b32

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

code/hud/hudtarget.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,14 +1751,18 @@ void hud_target_live_turret(int next_flag, int auto_advance, int only_player_tar
17511751
int num_live_turrets = 0;
17521752

17531753
// make sure we're targeting a ship
1754-
if (Player_ai->target_objnum == -1 && !auto_advance) {
1755-
snd_play(gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
1754+
if (Player_ai->target_objnum == -1) {
1755+
if (!auto_advance) {
1756+
snd_play(gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
1757+
}
17561758
return;
17571759
}
17581760

17591761
// only targeting subsystems on ship
1760-
if ((Objects[Player_ai->target_objnum].type != OBJ_SHIP) && (!auto_advance)) {
1761-
snd_play( gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
1762+
if (Objects[Player_ai->target_objnum].type != OBJ_SHIP) {
1763+
if (!auto_advance) {
1764+
snd_play( gamesnd_get_game_sound(GameSounds::TARGET_FAIL));
1765+
}
17621766
return;
17631767
}
17641768

0 commit comments

Comments
 (0)