Skip to content

Commit

Permalink
Fixed crash if plugins tried to access other plugins during world close
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Oct 28, 2010
1 parent a348b76 commit f41ba46
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions doc_construct.cpp
Expand Up @@ -528,12 +528,19 @@ int i;

// delete plugins

for (PluginListIterator pit = m_PluginList.begin ();
pit != m_PluginList.end ();
++pit)
delete *pit;
PluginListIterator pit = m_PluginList.begin ();

// we have to do it this way, because otherwise if a plugin attempts to access the
// plugin list (eg. BroadcastPlugin, Trace) during the delete operation, then it
// may call a plugin that was deleted a moment ago, but is still in the list.

while (pit != m_PluginList.end ())
{
CPlugin * pPlugin = *pit; // get this one
pit = m_PluginList.erase (pit); // remove from list, move onto next one
delete pPlugin; // delete *this* one
}

m_PluginList.clear ();

CloseLog (); // this writes out the log file postamble as well

Expand Down

0 comments on commit f41ba46

Please sign in to comment.