Bug 1366882 - Fix a resource leak - CID 1402588 r=erahm
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 24 May 2017 19:39:26 +0200
changeset 410960 021d3649e2fcc1b017b9cedb3bd10f7cc08ad33d
parent 410959 9c914937a358e1dac731194071f4be5c90741790
child 410961 365687db6288738e30dd76d926790e1cd16df651
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1366882, 1402588
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1366882 - Fix a resource leak - CID 1402588 r=erahm MozReview-Commit-ID: Al0Vlxewy0V
extensions/auth/nsHttpNegotiateAuth.cpp
--- a/extensions/auth/nsHttpNegotiateAuth.cpp
+++ b/extensions/auth/nsHttpNegotiateAuth.cpp
@@ -520,17 +520,17 @@ nsHttpNegotiateAuth::GenerateCredentials
     // be a continuation of an earlier call because GSSAPI authentication
     // often takes multiple round-trips to complete depending on the
     // context flags given.  We want to use MUTUAL_AUTHENTICATION which
     // generally *does* require multiple round-trips.  Don't assume
     // auth can be completed in just 1 call.
     //
     unsigned int len = strlen(challenge);
 
-    void *inToken, *outToken;
+    void *inToken = nullptr, *outToken;
     uint32_t inTokenLen, outTokenLen;
 
     if (len > kNegotiateLen) {
         challenge += kNegotiateLen;
         while (*challenge == ' ')
             challenge++;
         len = strlen(challenge);
 
@@ -540,24 +540,24 @@ nsHttpNegotiateAuth::GenerateCredentials
 
         //
         // Decode the response that followed the "Negotiate" token
         //
         nsresult rv =
             Base64Decode(challenge, len, (char**)&inToken, &inTokenLen);
 
         if (NS_FAILED(rv)) {
+            free(inToken);
             return rv;
         }
     }
     else {
         //
         // Initializing, don't use an input token.
         //
-        inToken = nullptr;
         inTokenLen = 0;
     }
 
     nsresult rv = module->GetNextToken(inToken, inTokenLen, &outToken, &outTokenLen);
 
     free(inToken);
 
     if (NS_FAILED(rv))