]> granicus.if.org Git - curl/commitdiff
imap_perform_authentication: fix memory leak
authorDaniel Stenberg <daniel@haxx.se>
Thu, 2 Oct 2014 21:01:45 +0000 (23:01 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 2 Oct 2014 21:01:45 +0000 (23:01 +0200)
Coverity CID 1215296. 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/imap.c

index 9fc472866d14a1166fc9713639dbc8ca0e4aaede..ee1bad2952982d6a16b613ff7fad22a2a6364367 100644 (file)
@@ -634,8 +634,6 @@ static CURLcode imap_perform_authentication(struct connectdata *conn)
     if(mech && (imapc->preftype & IMAP_TYPE_SASL)) {
       /* Perform SASL based authentication */
       result = imap_perform_authenticate(conn, mech, initresp, state1, state2);
-
-      Curl_safefree(initresp);
     }
     else if((!imapc->login_disabled) &&
             (imapc->preftype & IMAP_TYPE_CLEARTEXT))
@@ -648,6 +646,8 @@ static CURLcode imap_perform_authentication(struct connectdata *conn)
     }
   }
 
+  Curl_safefree(initresp);
+
   return result;
 }