From 0ee2fd7507c96b992f91f1b2caf5d7599962fb73 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 20 Aug 2009 17:01:33 +0000 Subject: [PATCH] Fix a division by zero bug Thanks to Sickness for reporting this and providing backtraces and for flakes for writing a first patch that Sickness tested. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1603 726aef4b-f618-498e-8847-2d620e286838 --- User.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/User.cpp b/User.cpp index 9ff8a4be..17006d78 100644 --- a/User.cpp +++ b/User.cpp @@ -704,6 +704,10 @@ CChan* CUser::FindChan(const CString& sName) const { } void CUser::JoinChans() { + // Avoid divsion by zero, it's bad! + if (m_vChans.size() == 0) + return; + // We start at a random offset into the channel list so that if your // first 3 channels are invite-only and you got MaxJoins == 3, ZNC will // still be able to join the rest of your channels.