Skip to content

Commit

Permalink
objmem: properly check for missing elements in freeAllEntitiesImpl
Browse files Browse the repository at this point in the history
It's forbidden to invoke `.erase()` on the end iterator,
so avoid calling the method by guarding this code path
by a `continue` + `ASSERT` combination.

Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson authored and past-due committed Sep 18, 2024
1 parent 9045591 commit 9f59a73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/objmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ static void freeAllEntitiesImpl(PerPlayerObjectLists<Entity, PlayerCount>& entit
for (auto* ent : list)
{
auto it = entityContainer.find(*ent);
ASSERT(it != entityContainer.end(), "%s not found in the global container!", Traits::entityName());
if (it == entityContainer.end()) {
ASSERT(false, "%s not found in the global container!", Traits::entityName());
continue;
}
entityContainer.erase(it);
}
list.clear();
Expand Down

0 comments on commit 9f59a73

Please sign in to comment.