Permalink
Browse files

fixed a null reference to pClient in hooks 'OnChanBufferStarting,OnCh…

…anBufferStarting,OnChanBufferEnding,OnChanBufferEnding', such that when pClient is NULL the hooks are called on all clients associated to that user
  • Loading branch information...
1 parent 0ccc815 commit 002b31d407437a2c81f0067346fbbb2d8e16db34 Jim Hull committed Sep 13, 2011
Showing with 29 additions and 17 deletions.
  1. +29 −17 Chan.cpp
View
@@ -544,28 +544,40 @@ void CChan::SendBuffer(CClient* pClient) {
const vector<CString>& vsBuffer = GetBuffer();
if (vsBuffer.size()) {
- bool bSkipStatusMsg = false;
- NETWORKMODULECALL(OnChanBufferStarting(*this, *pClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);
+ const vector<CClient*> & 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 ...
+
+ CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
+ bool bSkipStatusMsg = false;
+ NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);
+
+ if (!bSkipStatusMsg) {
+ m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
+ }
- if (!bSkipStatusMsg) {
- m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pClient);
- }
+ 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);
+ }
- 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 (!KeepBuffer()) {
+ ClearBuffer();
+ }
- 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);
+ }
- bSkipStatusMsg = false;
- NETWORKMODULECALL(OnChanBufferEnding(*this, *pClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);
+ if( pClient )
+ break;
- if (!bSkipStatusMsg) {
- m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pClient);
}
}
}

0 comments on commit 002b31d

Please sign in to comment.