]> granicus.if.org Git - curl/commitdiff
pop3_perform_authentication: fix memory leak
authorDaniel Stenberg <daniel@haxx.se>
Thu, 2 Oct 2014 21:07:06 +0000 (23:07 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 2 Oct 2014 21:07:06 +0000 (23:07 +0200)
Coverity CID 1215287. There's a potential risk for a memory leak in
here, and moving the free call to be unconditional seems like a cheap
price to remove the risk.

lib/pop3.c

index dc64f81065200836ad67776f59a455abff469e89..13528e3d562cb3db81efa0699f8809b7a6111fc1 100644 (file)
@@ -560,8 +560,6 @@ static CURLcode pop3_perform_authentication(struct connectdata *conn)
     if(mech && (pop3c->preftype & POP3_TYPE_SASL)) {
       /* Perform SASL based authentication */
       result = pop3_perform_auth(conn, mech, initresp, len, state1, state2);
-
-      Curl_safefree(initresp);
     }
 #ifndef CURL_DISABLE_CRYPTO_AUTH
     else if((pop3c->authtypes & POP3_TYPE_APOP) &&
@@ -580,6 +578,8 @@ static CURLcode pop3_perform_authentication(struct connectdata *conn)
     }
   }
 
+  Curl_safefree(initresp);
+
   return result;
 }