Skip to content

Commit

Permalink
Prevent a crash if droid in a group can't be found
Browse files Browse the repository at this point in the history
Co-authored-by: past-due <past-due@users.noreply.github.com>
  • Loading branch information
KJeff01 and past-due committed May 3, 2024
1 parent d8eebbd commit 981df67
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/group.cpp
Expand Up @@ -177,8 +177,14 @@ void DROID_GROUP::remove(DROID *psDroid)
if (psDroid->droidType != DROID_COMMAND || type != GT_COMMAND)
{
auto it = std::find(psList.begin(), psList.end(), psDroid);
ASSERT(it != psList.end(), "grpLeave: droid not found");
psList.erase(it);
if (it != psList.end())
{
psList.erase(it);
}
else
{
ASSERT(false, "grpLeave: droid not found");
}
}

psDroid->psGroup = nullptr;
Expand Down

0 comments on commit 981df67

Please sign in to comment.