diff --git a/mozilla/extensions/wallet/src/nsPasswordManager.cpp b/mozilla/extensions/wallet/src/nsPasswordManager.cpp index 449cd080a61..3ec995ad990 100644 --- a/mozilla/extensions/wallet/src/nsPasswordManager.cpp +++ b/mozilla/extensions/wallet/src/nsPasswordManager.cpp @@ -220,40 +220,42 @@ nsPasswordManager::FindPasswordEntry(char **hostURI, PRUnichar **username, PRUni // Emumerate through password elements while (hasMoreElements) { rv = enumerator->GetNext(getter_AddRefs(passwordElem)); - if (NS_SUCCEEDED(rv) && passwordElem) { - // Get the server URI stored as host - nsXPIDLCString thisHostURI; - passwordElem->GetHost(getter_Copies(thisHostURI)); + if (NS_FAILED(rv)) { + return rv; // could not unlock the database + } - nsXPIDLString thisUsername; - passwordElem->GetUser(getter_Copies(thisUsername)); + // Get the server URI stored as host + nsXPIDLCString thisHostURI; + passwordElem->GetHost(getter_Copies(thisHostURI)); - nsXPIDLString thisPassword; - passwordElem->GetPassword(getter_Copies(thisPassword)); + nsXPIDLString thisUsername; + passwordElem->GetUser(getter_Copies(thisUsername)); - // Check if any of the params are null (set by getter_Copies as - // preparation for output parameters) and treat them wild card - // entry matches or if they match with current password element - // attribute values. - PRBool hostURIOK = !*hostURI || thisHostURI.Equals(*hostURI); - PRBool usernameOK = !*username || thisUsername.Equals(*username); - PRBool passwordOK = !*password || thisPassword.Equals(*password); + nsXPIDLString thisPassword; + passwordElem->GetPassword(getter_Copies(thisPassword)); - // If a password match is found based on given input params, - // fill in those params which are passed in as empty strings. - if (hostURIOK && usernameOK && passwordOK) - { - if (!*hostURI) { - *hostURI = ToNewCString(thisHostURI); - } - if (!*username) { - *username = ToNewUnicode(thisUsername); - } - if (!*password) { - *password = ToNewUnicode(thisPassword); - } - break; + // Check if any of the params are null (set by getter_Copies as + // preparation for output parameters) and treat them wild card + // entry matches or if they match with current password element + // attribute values. + PRBool hostURIOK = !*hostURI || thisHostURI.Equals(*hostURI); + PRBool usernameOK = !*username || thisUsername.Equals(*username); + PRBool passwordOK = !*password || thisPassword.Equals(*password); + + // If a password match is found based on given input params, + // fill in those params which are passed in as empty strings. + if (hostURIOK && usernameOK && passwordOK) + { + if (!*hostURI) { + *hostURI = ToNewCString(thisHostURI); } + if (!*username) { + *username = ToNewUnicode(thisUsername); + } + if (!*password) { + *password = ToNewUnicode(thisPassword); + } + break; } enumerator->HasMoreElements(&hasMoreElements); } diff --git a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp index e7af7dc7ba9..a119cc7f1de 100644 --- a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp @@ -1609,7 +1609,11 @@ nsMsgIncomingServer::GetIsAuthenticated(PRBool *isAuthenticated) // Get password entry corresponding to the host URI we are passing in. rv = passwordMgr->FindPasswordEntry(&hostURI, getter_Copies(userName), getter_Copies(password)); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + // release hostURI + nsMemory::Free(hostURI); + return rv; + } // release hostURI nsMemory::Free(hostURI);