From aa5bd3b73b2c91e63bd7b9e223fc5c9796278dd2 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 6 Jul 2009 16:25:25 +0000 Subject: [PATCH] Fix a possible crash if users are deleted If a user is deleted while it is trying to connect to an IRC server, the IRC socket wasn't deleted together with the user. At some later point in time, the IRC socket will try to use the user object, which was already freed by now. Fix this by erasing IRC sockets together with their user object. Thanks to cnu for reporting this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1557 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/znc.cpp b/znc.cpp index 48342e9b..e8cbcd08 100644 --- a/znc.cpp +++ b/znc.cpp @@ -193,7 +193,9 @@ bool CZNC::HandleUserDeletion() #endif m_msUsers.erase(pUser->GetUserName()); - CIRCSock* pIRCSock = pUser->GetIRCSock(); + // Don't use pUser->GetIRCSock(), as that only returns something if the + // CIRCSock is already connected, not when it's still connecting! + CIRCSock* pIRCSock = (CIRCSock*) m_Manager.FindSockByName("IRC::" + pUser->GetUserName()); if (pIRCSock) { m_Manager.DelSockByAddr(pIRCSock);