From 002b31d407437a2c81f0067346fbbb2d8e16db34 Mon Sep 17 00:00:00 2001 From: Jim Hull Date: Mon, 12 Sep 2011 23:03:03 -0700 Subject: [PATCH] fixed a null reference to pClient in hooks 'OnChanBufferStarting,OnChanBufferStarting,OnChanBufferEnding,OnChanBufferEnding', such that when pClient is NULL the hooks are called on all clients associated to that user --- Chan.cpp | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Chan.cpp b/Chan.cpp index 9d7be68b..0f52b092 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -544,28 +544,40 @@ void CChan::SendBuffer(CClient* pClient) { const vector& vsBuffer = GetBuffer(); if (vsBuffer.size()) { - bool bSkipStatusMsg = false; - NETWORKMODULECALL(OnChanBufferStarting(*this, *pClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); + const vector & vClients = m_pNetwork->GetClients(); + for( size_t uClient = 0; uClient < vClients.size(); ++uClient ) { + // in the event that pClient is NULL, need to send this to all clients for the user + // I'm presuming here that pClient is listed inside vClients so thus vClients at this + // point can't be empty. Rework this if you like ... - if (!bSkipStatusMsg) { - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pClient); - } + CClient * pUseClient = ( pClient ? pClient : vClients[uClient] ); + bool bSkipStatusMsg = false; + NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); - for (unsigned int a = 0; a < vsBuffer.size(); a++) { - CString sLine(vsBuffer[a]); - NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, continue); - m_pNetwork->PutUser(sLine, pClient); - } + if (!bSkipStatusMsg) { + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient); + } - if (!KeepBuffer()) { - ClearBuffer(); - } + for (unsigned int a = 0; a < vsBuffer.size(); a++) { + CString sLine(vsBuffer[a]); + NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, continue); + m_pNetwork->PutUser(sLine, pUseClient); + } - bSkipStatusMsg = false; - NETWORKMODULECALL(OnChanBufferEnding(*this, *pClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); + if (!KeepBuffer()) { + ClearBuffer(); + } + + bSkipStatusMsg = false; + NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true); + + if (!bSkipStatusMsg) { + m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pUseClient); + } + + if( pClient ) + break; - if (!bSkipStatusMsg) { - m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pClient); } } }