Skip to content

Commit 1a130c7

Browse files
authored
Merge pull request #1199 from asarium/fix/highestObjectCrash
Fix negative array index
2 parents 695bee6 + f87a72b commit 1a130c7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

code/object/object.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,11 @@ void obj_free(int objnum)
452452

453453
Assert(Num_objects >= 0);
454454

455-
if (objnum == Highest_object_index)
456-
while (Objects[--Highest_object_index].type == OBJ_NONE);
457-
455+
if (objnum == Highest_object_index) {
456+
while (Highest_object_index >= 0 && Objects[Highest_object_index].type == OBJ_NONE) {
457+
--Highest_object_index;
458+
}
459+
}
458460
}
459461

460462
/**

0 commit comments

Comments
 (0)