From 9f1f8950f8673df7cc1eef6c8ded99a71b0966ba Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 27 Apr 2009 18:56:03 +0000 Subject: [PATCH] Fix crash bug in stickychan When you are already in #znc and you did 'stick znc' (# prefix missing!), stickychan caused segfaults or different weird behavior. This happened because stickychan didn't handle errors from CUser::AddChan(). AddChan() can only error out if the channel already exists, but since stickychan already checked this, were does the error come from? CChan's constructor does some sanity checks on the channel name. It automatically adds the proper channel prefix (most likely #) if it's missing. This means when stickychan checked for the channel "znc" it correctly didn't find one. When it then tried to add "znc", it really tried adding "#znc" which could fail if the channel was already added. Thanks to DM8Mydog for finding this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1500 726aef4b-f618-498e-8847-2d620e286838 --- modules/stickychan.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/stickychan.cpp b/modules/stickychan.cpp index 6f33c65a..ade0d009 100644 --- a/modules/stickychan.cpp +++ b/modules/stickychan.cpp @@ -86,7 +86,12 @@ public: pChan = new CChan(it->first, m_pUser, true); if (!it->second.empty()) pChan->SetKey(it->second); - m_pUser->AddChan(pChan); + if (!m_pUser->AddChan(pChan)) { + /* AddChan() deleted that channel */ + PutModule("Could not join [" + it->first + + "] (# prefix missing?)"); + continue; + } } if (!pChan->IsOn()) { PutModule("Joining [" + pChan->GetName() + "]");