diff options
author | Gaming4JC <g4jc@bulletmail.org> | 2018-09-26 18:29:45 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@bulletmail.org> | 2018-09-26 18:29:45 -0400 |
commit | 475a210a336da603f308d9163e3922b7cc285e0b (patch) | |
tree | f672785bb2b3aa87804c2bce3a9a0c76c0bdab9e /netwerk/protocol | |
parent | e3508f55bed8a463d298021633dbc7d079c9d764 (diff) | |
download | UXP-475a210a336da603f308d9163e3922b7cc285e0b.tar UXP-475a210a336da603f308d9163e3922b7cc285e0b.tar.gz UXP-475a210a336da603f308d9163e3922b7cc285e0b.tar.lz UXP-475a210a336da603f308d9163e3922b7cc285e0b.tar.xz UXP-475a210a336da603f308d9163e3922b7cc285e0b.zip |
backport mozbug 1444532 - fix a leak in SHA256 in nsHttpConnectionInfo.cpp r=mayhemer
The original code (from bug 1200802) declared an XPCOM object as a static bare pointer,
which for future reference is probably never the right thing to do. It might have worked if
it was cleared before shutdown but it never was.
Diffstat (limited to 'netwerk/protocol')
-rw-r--r-- | netwerk/protocol/http/nsHttpConnectionInfo.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp index e965fd1cc..93a40843c 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp +++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp @@ -15,32 +15,26 @@ #include "nsHttpConnectionInfo.h" #include "mozilla/net/DNS.h" -#include "prnetdb.h" -#include "nsICryptoHash.h" #include "nsComponentManagerUtils.h" +#include "nsICryptoHash.h" #include "nsIProtocolProxyService.h" +#include "nsNetCID.h" +#include "prnetdb.h" static nsresult SHA256(const char* aPlainText, nsAutoCString& aResult) { - static nsICryptoHash* hasher = nullptr; nsresult rv; - if (!hasher) { - rv = CallCreateInstance("@mozilla.org/security/hash;1", &hasher); - if (NS_FAILED(rv)) { - LOG(("nsHttpDigestAuth: no crypto hash!\n")); - return rv; - } + nsCOMPtr<nsICryptoHash> hasher = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv); + if (NS_FAILED(rv)) { + LOG(("nsHttpDigestAuth: no crypto hash!\n")); + return rv; } - rv = hasher->Init(nsICryptoHash::SHA256); NS_ENSURE_SUCCESS(rv, rv); - rv = hasher->Update((unsigned char*) aPlainText, strlen(aPlainText)); NS_ENSURE_SUCCESS(rv, rv); - - rv = hasher->Finish(false, aResult); - return rv; + return hasher->Finish(false, aResult); } namespace mozilla { |