]> granicus.if.org Git - curl/commitdiff
ftp: fixed a NULL pointer dereference on OOM
authorDan Fandrich <dan@coneharvesters.com>
Sat, 25 Feb 2017 21:55:46 +0000 (22:55 +0100)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 25 Feb 2017 21:55:46 +0000 (22:55 +0100)
lib/ftp.c

index 4d5d07a11a68403718131e525191c5300fac102a..867c97994d612655d6c29b3746beb1ba6c81f662 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2040,11 +2040,14 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
     /* this just dumps information about this second connection */
     ftp_pasv_verbose(conn, addr->addr, ftpc->newhost, connectport);
 
+  Curl_resolv_unlock(data, addr); /* we're done using this address */
+
   Curl_safefree(conn->secondaryhostname);
-  conn->secondaryhostname = strdup(ftpc->newhost);
   conn->secondary_port = ftpc->newport;
+  conn->secondaryhostname = strdup(ftpc->newhost);
+  if(!conn->secondaryhostname)
+    return CURLE_OUT_OF_MEMORY;
 
-  Curl_resolv_unlock(data, addr); /* we're done using this address */
   conn->bits.do_more = TRUE;
   state(conn, FTP_STOP); /* this phase is completed */