Skip to content

Commit 6c42d9c

Browse files
committed
prevent negative array index when AI has no target
1 parent a9ff3c5 commit 6c42d9c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

code/scripting/api/objs/ship.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ ADE_VIRTVAR(TargetSubsystem, l_Ship, "subsystem", "Target subsystem of ship.", "
811811
}
812812
}
813813

814-
return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(&Objects[aip->target_objnum], aip->targeted_subsys)));
814+
return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(aip->target_objnum >= 0 ? &Objects[aip->target_objnum] : nullptr, aip->targeted_subsys)));
815815
}
816816

817817
ADE_VIRTVAR(Team, l_Ship, "team", "Ship's team", "team", "Ship team, or invalid team handle if ship handle is invalid")

0 commit comments

Comments
 (0)