]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: fix bug in failed init
authorStefan Eissing <stefan@eissing.org>
Tue, 6 May 2025 10:59:28 +0000 (12:59 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 6 May 2025 11:22:12 +0000 (13:22 +0200)
torture tests revealed that memory was not released correctly when FTP's
connection setup failed an allocation.

Follow-up from a2d90d4ba5076643b5af9978c4

Closes #17258

lib/ftp.c

index ff57a57b3e6ad517fb824200c4b41e34014e1603..925baf6585afc89b928d35539417388e0192760c 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -4424,7 +4424,6 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,
   if(data->set.str[STRING_FTP_ACCOUNT]) {
     ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]);
     if(!ftpc->account) {
-      free(ftp);
       Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
       return CURLE_OUT_OF_MEMORY;
     }
@@ -4434,7 +4433,6 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,
       strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
     if(!ftpc->alternative_to_user) {
       Curl_safefree(ftpc->account);
-      free(ftp);
       Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
       return CURLE_OUT_OF_MEMORY;
     }