Fix a crash with WebMods and deleting User

If a user who is currently logged in to WebMods is deleted, his CWebSession
still kept a stale CUser pointer around. The next time he loaded a web page,
Bad Things(tm) happened.

This is fixed by deleting all of a user's sessions when that user is deleted.

Thanks to DarthGandalf for spotting the bug and writing the patch.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1827 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-03-11 17:29:36 +00:00
parent a74c2a4625
commit 4303c3c200
4 changed files with 24 additions and 3 deletions
+12 -1
View File
@@ -12,7 +12,7 @@
#include <sstream>
// Sessions are valid for a day, (24h, ...)
TCacheMap<CString, CSmartPtr<CWebSession> > CWebSock::m_mspSessions(24 * 60 * 60 * 1000);
CWebSessionMap CWebSock::m_mspSessions(24 * 60 * 60 * 1000);
CZNCTagHandler::CZNCTagHandler(CWebSock& WebSock) : CTemplateTagHandler(), m_WebSock(WebSock) {
}
@@ -66,6 +66,17 @@ size_t CWebSession::AddSuccess(const CString& sMessage) {
return m_vsSuccessMsgs.size();
}
void CWebSessionMap::FinishUserSessions(const CUser& User) {
iterator it = m_mItems.begin();
while (it != m_mItems.end()) {
if (it->second.second->GetUser() == &User) {
m_mItems.erase(it++);
} else {
++it;
}
}
}
void CWebAuth::AcceptedLogin(CUser& User) {
if (m_pWebSock) {