Skip to content

Commit

Permalink
object_list_iteration.h: add early return to mutating_list_iterate
Browse files Browse the repository at this point in the history
This is sort of a hack/workaround to prevent crashes related to
`TargetMissing_` static instance of `BASE_OBJECT` defined
in the `multibot.cpp`.

By the time this object gets destroyed, audio-related global
vars are already destroyed and this object references one of
them in its destructor via `audio_RemoveObj(this)` call.

This should be addressed later, of course. But still,
not crashing is better than crashing and early return
is never bad.

Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson committed Jan 23, 2024
1 parent a4910b8 commit c1eb169
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/framework/object_list_iteration.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ void mutating_list_iterate(std::list<ObjectType*>& list, MaybeErasingLoopBodyHan
"Unsupported loop body handler signature: "
"should return IterationResult and take either an ObjectType* or an iterator");

if (list.empty())
{
return;
}

typename std::remove_reference_t<decltype(list)>::iterator it = list.begin(), itNext;
while (it != list.end())
{
Expand Down

0 comments on commit c1eb169

Please sign in to comment.