mirror of
https://github.com/znc/znc.git
synced 2026-07-03 08:21:57 +02:00
Fix a NULL pointer dereference with traffic stats
When something requested traffic statistics while there was an unauthenticated connection to ZNC, there was a NULL pointer dereference. Fix this by making the code saner and removing all NULL pointer dereferences. ;) Thanks to various people who reported this. A special thank you goes to Woet who helped debugging this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2026 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -1927,18 +1927,18 @@ CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair &Users,
|
||||
}
|
||||
|
||||
for (CSockManager::const_iterator it = m_Manager.begin(); it != m_Manager.end(); ++it) {
|
||||
CUser *pUser = NULL;
|
||||
if ((*it)->GetSockName().Left(5) == "IRC::") {
|
||||
CIRCSock *p = (CIRCSock *) *it;
|
||||
ret[p->GetUser()->GetUserName()].first += p->GetBytesRead();
|
||||
ret[p->GetUser()->GetUserName()].second += p->GetBytesWritten();
|
||||
uiUsers_in += p->GetBytesRead();
|
||||
uiUsers_out += p->GetBytesWritten();
|
||||
pUser = ((CIRCSock *) *it)->GetUser();
|
||||
} else if ((*it)->GetSockName().Left(5) == "USR::") {
|
||||
CClient *p = (CClient *) *it;
|
||||
ret[p->GetUser()->GetUserName()].first += p->GetBytesRead();
|
||||
ret[p->GetUser()->GetUserName()].second += p->GetBytesWritten();
|
||||
uiUsers_in += p->GetBytesRead();
|
||||
uiUsers_out += p->GetBytesWritten();
|
||||
pUser = ((CClient*) *it)->GetUser();
|
||||
}
|
||||
|
||||
if (pUser) {
|
||||
ret[pUser->GetUserName()].first += (*it)->GetBytesRead();
|
||||
ret[pUser->GetUserName()].second += (*it)->GetBytesWritten();
|
||||
uiUsers_in += (*it)->GetBytesRead();
|
||||
uiUsers_out += (*it)->GetBytesWritten();
|
||||
} else {
|
||||
uiZNC_in += (*it)->GetBytesRead();
|
||||
uiZNC_out += (*it)->GetBytesWritten();
|
||||
|
||||
Reference in New Issue
Block a user