From e2ec6d960dc7a06b2d6fb7f2ed1e6b57d9ce4bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 27 Apr 2015 18:42:45 -0400 Subject: [PATCH] sipaccount: fix pointer to deinitialised local variable Refs #71790 Change-Id: Ica542e01c1f6a4d8305b3653923ed6a0078e6e41 --- src/sip/sipaccount.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 7bcfb18e74..f26096b4f7 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -1653,25 +1653,19 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str size_t i = 0; for (const auto &item : credentials_) { - map<string, string>::const_iterator val = item.find(Conf::CONFIG_ACCOUNT_PASSWORD); - const std::string password = val != item.end() ? val->second : ""; - int dataType = (md5HashingEnabled and password.length() == 32) - ? PJSIP_CRED_DATA_DIGEST - : PJSIP_CRED_DATA_PLAIN_PASSWD; - - val = item.find(Conf::CONFIG_ACCOUNT_USERNAME); - + auto val = item.find(Conf::CONFIG_ACCOUNT_USERNAME); if (val != item.end()) cred_[i].username = pj_str((char*) val->second.c_str()); - cred_[i].data = pj_str((char*) password.c_str()); - val = item.find(Conf::CONFIG_ACCOUNT_REALM); - if (val != item.end()) cred_[i].realm = pj_str((char*) val->second.c_str()); - cred_[i].data_type = dataType; + val = item.find(Conf::CONFIG_ACCOUNT_PASSWORD); + cred_[i].data = pj_str((char*) (val != item.end() ? val->second.c_str() : "")); + cred_[i].data_type = (md5HashingEnabled and cred_[i].data.slen == 32) + ? PJSIP_CRED_DATA_DIGEST + : PJSIP_CRED_DATA_PLAIN_PASSWD; cred_[i].scheme = pj_str((char*) "digest"); ++i; } -- GitLab