From bf8b1624c92c2553312161d5806a2042cee38962 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Wed, 31 Aug 2011 01:14:18 +0000 Subject: [PATCH] Unload user and network modules once all the clients are gone and we are disconencted from any IRC servers. The OnIRCDisconnected module call would cause a segmentation fault because it would try m_pNetwork->GetModules().GetNetwork(). GetModules() would return NULL. --- IRCNetwork.cpp | 8 ++++---- User.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/IRCNetwork.cpp b/IRCNetwork.cpp index 7610d0ff..98b11544 100644 --- a/IRCNetwork.cpp +++ b/IRCNetwork.cpp @@ -134,10 +134,6 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork *pNetwork, bool bCloneC } CIRCNetwork::~CIRCNetwork() { - // Delete modules (this unloads all modules) - delete m_pModules; - m_pModules = NULL; - // Delete clients for (vector::const_iterator it = m_vClients.begin(); it != m_vClients.end(); ++it) { CZNC::Get().GetManager().DelSockByAddr(*it); @@ -147,6 +143,10 @@ CIRCNetwork::~CIRCNetwork() { // Delete servers DelServers(); + // Delete modules (this unloads all modules) + delete m_pModules; + m_pModules = NULL; + // Delete Channels for (vector::const_iterator it = m_vChans.begin(); it != m_vChans.end(); ++it) { delete *it; diff --git a/User.cpp b/User.cpp index 80767798..f3ee3780 100644 --- a/User.cpp +++ b/User.cpp @@ -88,10 +88,6 @@ CUser::CUser(const CString& sUserName) } CUser::~CUser() { - // Delete modules (unloads all modules!) - delete m_pModules; - m_pModules = NULL; - // Delete networks for (unsigned int c = 0; c < m_vIRCNetworks.size(); c++) { CIRCNetwork* pNetwork = m_vIRCNetworks[c]; @@ -106,6 +102,10 @@ CUser::~CUser() { } m_vClients.clear(); + // Delete modules (unloads all modules!) + delete m_pModules; + m_pModules = NULL; + CZNC::Get().GetManager().DelCronByAddr(m_pUserTimer); CZNC::Get().AddBytesRead(BytesRead());