Skip to content

Commit

Permalink
Fix use-after-free which may happen during shutdown
Browse files Browse the repository at this point in the history
If a module, e.g. keepnick, tries to remove a timer in
OnIRCDisconnected.

Thanks to KindOne for the report.
  • Loading branch information
DarthGandalf committed Mar 31, 2013
1 parent 20c5c7d commit 8fdb530
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/keepnick.cpp
Expand Up @@ -121,7 +121,7 @@ class CKeepNickMod : public CModule {
return;

m_pTimer->Stop();
RemTimer(m_pTimer->GetName());
RemTimer(m_pTimer);
m_pTimer = NULL;
}

Expand Down
5 changes: 5 additions & 0 deletions src/znc.cpp
Expand Up @@ -51,6 +51,11 @@ CZNC::~CZNC() {

for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); ++a) {
a->second->GetModules().UnloadAll();

const vector<CIRCNetwork*>& networks = a->second->GetNetworks();
for (vector<CIRCNetwork*>::const_iterator b = networks.begin(); b != networks.end(); ++b) {
(*b)->GetModules().UnloadAll();
}
}

for (size_t b = 0; b < m_vpListeners.size(); b++) {
Expand Down

0 comments on commit 8fdb530

Please sign in to comment.