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
This commit is contained in:
psychon
2009-07-06 16:25:25 +00:00
parent 4c14b1bf61
commit aa5bd3b73b
+3 -1
View File
@@ -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);