From 6f866109be03f25924831405ca59976993e3ee3e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 26 Dec 2025 12:52:34 +0100 Subject: [PATCH] ftp: return from ftp_state_use_port immediately on OOM --- lib/ftp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ftp.c b/lib/ftp.c index 13fae6a4e4..9bfcab3da0 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1026,8 +1026,11 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, /* step 2, create a socket for the requested address */ error = 0; for(ai = res; ai; ai = ai->ai_next) { - if(Curl_socket_open(data, ai, NULL, - Curl_conn_get_transport(data, conn), &portsock)) { + result = Curl_socket_open(data, ai, NULL, + Curl_conn_get_transport(data, conn), &portsock); + if(result) { + if(result == CURLE_OUT_OF_MEMORY) + goto out; error = SOCKERRNO; continue; }