Skip to content

Commit

Permalink
Fix possible crash at removing invalid creatureEvents (otland#4673)
Browse files Browse the repository at this point in the history
correction of the loop
  • Loading branch information
kygov committed May 7, 2024
1 parent a577601 commit 098ed9c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/creatureevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ void CreatureEvents::clear(bool fromLua)

void CreatureEvents::removeInvalidEvents()
{
for (auto it = creatureEvents.begin(); it != creatureEvents.end(); ++it) {
for (auto it = creatureEvents.begin(); it != creatureEvents.end();) {
if (it->second.getScriptId() == 0) {
creatureEvents.erase(it->second.getName());
it = creatureEvents.erase(it);
} else {
++it;
}
}
}
Expand Down

0 comments on commit 098ed9c

Please sign in to comment.