Fix a crash bug in WebModules

WebModules use CHTTPSock for the HTTP server. That class requires a CModule
instance for working since it's based on CSocket. This was solved by creating a
fake module instance which is destroyed when the socket is destroyed.

The problem here was that CSocket's destructor tried to access that module
instance which was already destroyed resulting in a use-after-free.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1824 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-03-10 19:16:38 +00:00
parent f6f7dce129
commit a7d26bb598
2 changed files with 11 additions and 7 deletions

View File

@@ -118,10 +118,10 @@ CWebSock::~CWebSock() {
}
// If the module IsFake() then it was created as a dummy and needs to be deleted
CModule* pMod = GetModule();
if (pMod && pMod->IsFake()) {
pMod->UnlinkSocket(this);
delete pMod;
if (m_pModule && m_pModule->IsFake()) {
m_pModule->UnlinkSocket(this);
delete m_pModule;
m_pModule = NULL;
}
}