Skip to content

Commit

Permalink
Unload user and network modules once all the clients are gone and we …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
kylef committed Aug 31, 2011
1 parent 75d7cdf commit bf8b162
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions IRCNetwork.cpp
Expand Up @@ -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<CClient*>::const_iterator it = m_vClients.begin(); it != m_vClients.end(); ++it) {
CZNC::Get().GetManager().DelSockByAddr(*it);
Expand All @@ -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<CChan*>::const_iterator it = m_vChans.begin(); it != m_vChans.end(); ++it) {
delete *it;
Expand Down
8 changes: 4 additions & 4 deletions User.cpp
Expand Up @@ -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];
Expand All @@ -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());
Expand Down

0 comments on commit bf8b162

Please sign in to comment.