]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: return from ftp_state_use_port immediately on OOM
authorDaniel Stenberg <daniel@haxx.se>
Fri, 26 Dec 2025 11:52:34 +0000 (12:52 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 27 Dec 2025 15:25:52 +0000 (16:25 +0100)
Closes #20100

lib/ftp.c

index 13fae6a4e48e5734c86643604181e8c41ac3af3e..27e4c8aadd6303576943b4098e0eaeebd2692066 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1026,8 +1026,12 @@ 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;
+      result = CURLE_FTP_PORT_FAILED;
       error = SOCKERRNO;
       continue;
     }