diff --git a/znc.cpp b/znc.cpp index 5c76a6c9..c9e41d97 100644 --- a/znc.cpp +++ b/znc.cpp @@ -782,13 +782,13 @@ bool CZNC::ParseConfig(const CString& sConfig) { } else if (sTag.CaseCmp("User") == 0) { CString sErr; - if (!pUser->IsValid(sErr)) { + if (!AddUser(pUser, sErr)) { CUtils::PrintError("Invalid user [" + pUser->GetUserName() + "] " + sErr); + pUser->SetBeingDeleted(true); + delete pUser; return false; } - AddUser(pUser); - pUser = NULL; continue; } @@ -1204,15 +1204,13 @@ bool CZNC::DeleteUser(const CString& sUsername) { return true; } -bool CZNC::AddUser(CUser* pUser) { - CString sErr; - - if (pUser->IsValid(sErr)) { +bool CZNC::AddUser(CUser* pUser, CString& sErrorRet) { + if (pUser->IsValid(sErrorRet)) { m_msUsers[pUser->GetUserName()] = pUser; return true; } - DEBUG_ONLY(cout << "Invalid user [" << pUser->GetUserName() << "] - [" << sErr << "]" << endl); + DEBUG_ONLY(cout << "Invalid user [" << pUser->GetUserName() << "] - [" << sErrorRet << "]" << endl); return false; } diff --git a/znc.h b/znc.h index d2efbc41..a9607ac6 100644 --- a/znc.h +++ b/znc.h @@ -135,7 +135,7 @@ public: static CZNC& Get(); CUser* FindUser(const CString& sUsername); bool DeleteUser(const CString& sUsername); - bool AddUser(CUser* pUser); + bool AddUser(CUser* pUser, CString& sErrorRet); const map & GetUserMap() const { return( m_msUsers ); } // Message of the Day