]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
asyn-ares: abort with OOM error when Curl_dnscache_mk_entry fails
authorDaniel Stenberg <daniel@haxx.se>
Wed, 21 Jan 2026 09:08:27 +0000 (10:08 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 21 Jan 2026 22:32:18 +0000 (23:32 +0100)
Closes #20385

lib/asyn-ares.c

index 077b97d1275cb3731aa8119e6f5d598964f6decf..df8a603cc47dc1055efc64bc36b9feca2e86e7ad 100644 (file)
@@ -335,10 +335,13 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
         Curl_dnscache_mk_entry(data, ares->temp_ai,
                                data->state.async.hostname, 0,
                                data->state.async.port, FALSE);
-      if(data->state.async.dns)
-        ares->temp_ai = NULL; /* temp_ai now owned by entry */
+      if(!data->state.async.dns) {
+        result = CURLE_OUT_OF_MEMORY;
+        goto out;
+      }
+      ares->temp_ai = NULL; /* temp_ai now owned by entry */
 #ifdef HTTPSRR_WORKS
-      if(data->state.async.dns) {
+      {
         struct Curl_https_rrinfo *lhrr = Curl_httpsrr_dup_move(&ares->hinfo);
         if(!lhrr)
           result = CURLE_OUT_OF_MEMORY;
@@ -346,7 +349,7 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
           data->state.async.dns->hinfo = lhrr;
       }
 #endif
-      if(!result && data->state.async.dns)
+      if(!result)
         result = Curl_dnscache_add(data, data->state.async.dns);
     }
     /* if we have not found anything, report the proper