Fix a couple of issues pointed out by https://scan.coverity.com/

This commit is contained in:
Alexey Sokolov
2016-12-26 17:22:09 +00:00
parent b666931883
commit 2fcde9f2e1
6 changed files with 23 additions and 42 deletions
+4 -4
View File
@@ -46,10 +46,10 @@ class CZNCSock : public Csock, public CCoreTranslationMixin {
m_ssTrustedFingerprints = ssFPs;
}
void SetTrustAllCerts(const bool bTrustAll = false) { m_bTrustAllCerts = bTrustAll; }
void SetTrustAllCerts(bool bTrustAll) { m_bTrustAllCerts = bTrustAll; }
bool GetTrustAllCerts() const { return m_bTrustAllCerts; }
void SetTrustPKI(const bool bTrustPKI = true) { m_bTrustPKI = bTrustPKI; }
void SetTrustPKI(bool bTrustPKI) { m_bTrustPKI = bTrustPKI; }
bool GetTrustPKI() const { return m_bTrustPKI; }
void SetEncoding(const CString&);
@@ -66,8 +66,8 @@ class CZNCSock : public Csock, public CCoreTranslationMixin {
CString m_sHostToVerifySSL;
SCString m_ssTrustedFingerprints;
SCString m_ssCertVerificationErrors;
bool m_bTrustAllCerts;
bool m_bTrustPKI;
bool m_bTrustAllCerts = false;
bool m_bTrustPKI = true;
};
enum EAddrType { ADDR_IPV4ONLY, ADDR_IPV6ONLY, ADDR_ALL };
+7 -15
View File
@@ -549,28 +549,20 @@ class CAdminMod : public CModule {
const CString sNetwork = sLine.Token(3);
const CString sValue = sLine.Token(4, true);
CUser* pUser = nullptr;
CIRCNetwork* pNetwork = nullptr;
if (sValue.empty()) {
PutModule(
"Usage: SetNetwork <variable> <username> <network> <value>");
return;
}
if (sUsername.empty()) {
pUser = GetUser();
pNetwork = CModule::GetNetwork();
} else {
pUser = FindUser(sUsername);
if (!pUser) {
return;
}
CUser* pUser = FindUser(sUsername);
if (!pUser) {
return;
}
pNetwork = FindNetwork(pUser, sNetwork);
if (!pNetwork && !sNetwork.empty()) {
return;
}
CIRCNetwork* pNetwork = FindNetwork(pUser, sNetwork);
if (!pNetwork) {
return;
}
if (sVar.Equals("nick")) {
+1 -1
View File
@@ -225,8 +225,8 @@ class ZNC_EXPORT_LIB_EXPORT CPyTimer : public CTimer {
: CTimer(pModule, uInterval, uCycles, sLabel, sDescription),
m_pyObj(pyObj) {
Py_INCREF(pyObj);
pModule->AddTimer(this);
m_pModPython = pModule->GetModPython();
pModule->AddTimer(this);
}
void RunJob() override;
PyObject* GetPyObj() { return m_pyObj; }
+6 -7
View File
@@ -136,7 +136,7 @@ class CModTcl : public CModule {
Tcl_CreateCommand(interp, "exit", tcl_exit, this, nullptr);
if (!sMyArgs.empty()) {
i = Tcl_EvalFile(interp, sMyArgs.c_str());
int i = Tcl_EvalFile(interp, sMyArgs.c_str());
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -171,7 +171,7 @@ class CModTcl : public CModule {
void TclUpdate() {
while (Tcl_DoOneEvent(TCL_DONT_WAIT)) {
}
i = Tcl_Eval(interp, "Binds::ProcessTime");
int i = Tcl_Eval(interp, "Binds::ProcessTime");
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -212,7 +212,7 @@ class CModTcl : public CModule {
CString sCommand = "Binds::ProcessPubm {" + sNick + "} {" + sHost +
"} - {" + sChannel + "} {" + sMes + "}";
i = Tcl_Eval(interp, sCommand.c_str());
int i = Tcl_Eval(interp, sCommand.c_str());
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -227,7 +227,7 @@ class CModTcl : public CModule {
CString sCommand = "Binds::ProcessMsgm {" + sNick + "} {" + sHost +
"} - {" + sMes + "}";
i = Tcl_Eval(interp, sCommand.c_str());
int i = Tcl_Eval(interp, sCommand.c_str());
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -249,7 +249,7 @@ class CModTcl : public CModule {
sCommand = "Binds::ProcessNick {" + sOldNick + "} {" + sHost +
"} - {" + vChans[n]->GetName() + "} {" + sNewNickTmp +
"}";
i = Tcl_Eval(interp, sCommand.c_str());
int i = Tcl_Eval(interp, sCommand.c_str());
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -266,7 +266,7 @@ class CModTcl : public CModule {
CString sCommand = "Binds::ProcessKick {" + sOpNick + "} {" + sOpHost +
"} - {" + Channel.GetName() + "} {" + sNick + "} {" +
sMessage + "}";
i = Tcl_Eval(interp, sCommand.c_str());
int i = Tcl_Eval(interp, sCommand.c_str());
if (i != TCL_OK) {
PutModule(Tcl_GetStringResult(interp));
}
@@ -274,7 +274,6 @@ class CModTcl : public CModule {
private:
Tcl_Interp* interp;
int i;
static CString argvit(const char* argv[], unsigned int end,
unsigned int begin, CString delim) {
+1 -2
View File
@@ -472,8 +472,7 @@ void CFile::Close() {
void CFile::ClearBuffer() { m_sBuffer.clear(); }
bool CFile::TryExLock(const CString& sLockFile, int iFlags) {
Open(sLockFile, iFlags);
return TryExLock();
return Open(sLockFile, iFlags) && TryExLock();
}
bool CFile::TryExLock() { return Lock(F_WRLCK, false); }
+4 -13
View File
@@ -1252,7 +1252,7 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) {
CUtils::PrintMessage("Loading user [" + sUserName + "]");
CUser* pUser = new CUser(sUserName);
std::unique_ptr<CUser> pUser(new CUser(sUserName));
if (!m_sStatusPrefix.empty()) {
if (!pUser->SetStatusPrefix(m_sStatusPrefix)) {
@@ -1265,35 +1265,26 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) {
if (!pUser->ParseConfig(pSubConf, sError)) {
CUtils::PrintError(sError);
delete pUser;
pUser = nullptr;
return false;
}
if (!pSubConf->empty()) {
sError = "Unhandled lines in config for User [" + sUserName + "]!";
CUtils::PrintError(sError);
DumpConfig(pSubConf);
return false;
}
CString sErr;
if (!AddUser(pUser, sErr, true)) {
sError = "Invalid user [" + pUser->GetUserName() + "] " + sErr;
if (!AddUser(pUser.release(), sErr, true)) {
sError = "Invalid user [" + sUserName + "] " + sErr;
}
if (!sError.empty()) {
CUtils::PrintError(sError);
if (pUser) {
pUser->SetBeingDeleted(true);
delete pUser;
pUser = nullptr;
}
pUser->SetBeingDeleted(true);
return false;
}
pUser = nullptr;
}
if (m_msUsers.empty()) {