Skip to content

Commit f41ba46

Browse files
committed
Fixed crash if plugins tried to access other plugins during world close
1 parent a348b76 commit f41ba46

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

doc_construct.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,19 @@ int i;
528528

529529
// delete plugins
530530

531-
for (PluginListIterator pit = m_PluginList.begin ();
532-
pit != m_PluginList.end ();
533-
++pit)
534-
delete *pit;
531+
PluginListIterator pit = m_PluginList.begin ();
532+
533+
// we have to do it this way, because otherwise if a plugin attempts to access the
534+
// plugin list (eg. BroadcastPlugin, Trace) during the delete operation, then it
535+
// may call a plugin that was deleted a moment ago, but is still in the list.
536+
537+
while (pit != m_PluginList.end ())
538+
{
539+
CPlugin * pPlugin = *pit; // get this one
540+
pit = m_PluginList.erase (pit); // remove from list, move onto next one
541+
delete pPlugin; // delete *this* one
542+
}
535543

536-
m_PluginList.clear ();
537544

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

0 commit comments

Comments
 (0)