From 3e2b71263f19eb0eb0390823e27b753283418a62 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 14 Jul 2008 10:42:27 +0000 Subject: [PATCH] Fix a potential crash bug on channel part (CChan::RemNick()) This function didn't properly check it had a valid iterator *before* using this iterator (.begin()->second). Now we first check if that iterator is valid (size() is *not* zero) before we run this. No behaviour is changed, but the bug is gone. Yay. ;) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1133 726aef4b-f618-498e-8847-2d620e286838 --- Chan.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Chan.cpp b/Chan.cpp index 6fa94096..2124a2b0 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -530,11 +530,14 @@ bool CChan::RemNick(const CString& sNick) { delete it->second; m_msNicks.erase(it); - CNick* pNick = m_msNicks.begin()->second; - if ((m_msNicks.size() == 1) && (!pNick->HasPerm(Op)) && (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0)) { - if (AutoCycle()) { - Cycle(); + if (m_msNicks.size() == 1) { + CNick* pNick = m_msNicks.begin()->second; + + if (!pNick->HasPerm(Op) && pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { + if (AutoCycle()) { + Cycle(); + } } }