Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a NULL pointer issue on CChan::SaveBuff

I also cleaned up a little and loop over vClients once instead of twice
  • Loading branch information...
commit 74738a20b7b99682711b4b3207af086cadcc4f40 1 parent 94ffcbe
@kylef kylef authored
Showing with 6 additions and 16 deletions.
  1. +6 −16 src/Chan.cpp
View
22 src/Chan.cpp
@@ -527,8 +527,8 @@ void CChan::SendBuffer(CClient* pClient) {
if (!m_Buffer.IsEmpty()) {
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
+ CClient * pUseClient = (pClient ? pClient : vClients[uClient]);
- CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
bool bSkipStatusMsg = false;
NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);
@@ -538,26 +538,13 @@ void CChan::SendBuffer(CClient* pClient) {
unsigned int uSize = m_Buffer.Size();
for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
- CString sLine = m_Buffer.GetLine(uIdx, *pClient);
+ CString sLine = m_Buffer.GetLine(uIdx, *pUseClient);
NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, continue);
m_pNetwork->PutUser(sLine, pUseClient);
}
- if (pClient)
- break;
-
- }
-
- if (!KeepBuffer()) {
- ClearBuffer();
- }
-
- for ( size_t uClient = 0; uClient < vClients.size(); ++uClient) {
-
- CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
- bool bSkipStatusMsg = false;
+ 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);
}
@@ -566,6 +553,9 @@ void CChan::SendBuffer(CClient* pClient) {
break;
}
+ if (!KeepBuffer()) {
+ ClearBuffer();
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.