ftp: fix bug in failed init

torture tests revealed that memory was not released correctly when FTP's
connection setup failed an allocation.

Follow-up from a2d90d4ba5

Closes #17258
This commit is contained in:
Stefan Eissing 2025-05-06 12:59:28 +02:00 committed by Daniel Stenberg
parent 777c5209df
commit a30830db78
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -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;
}