]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: don't touch the multi handle when closing internal handles
authorDaniel Stenberg <daniel@haxx.se>
Thu, 19 Oct 2023 07:24:27 +0000 (09:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 20 Oct 2023 14:59:43 +0000 (16:59 +0200)
Reported-by: Maksymilian Arciemowicz
Closes #12165

lib/doh.c
lib/url.c

index 9f86631543f1a4887d592e2a21cef37e57f4ff53..9be32d3bc50a9a28abbbfe679e3635618db4919a 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -373,7 +373,7 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
   int slot;
   struct dohdata *dohp;
   struct connectdata *conn = data->conn;
-  *waitp = TRUE; /* this never returns synchronously */
+  *waitp = FALSE;
   (void)hostname;
   (void)port;
 
@@ -413,12 +413,14 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
     dohp->pending++;
   }
 #endif
+  *waitp = TRUE; /* this never returns synchronously */
   return NULL;
 
 error:
   curl_slist_free_all(dohp->headers);
   data->req.doh->headers = NULL;
   for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
+    (void)curl_multi_remove_handle(data->multi, dohp->probe[slot].easy);
     Curl_close(&dohp->probe[slot].easy);
   }
   Curl_safefree(data->req.doh);
index 61dad442ddbf71e5625a7055be5490c5ae415c43..e2d97e21d6f9274494ab3c04191e197e2de99dc6 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -363,16 +363,18 @@ CURLcode Curl_close(struct Curl_easy **datap)
   /* Detach connection if any is left. This should not be normal, but can be
      the case for example with CONNECT_ONLY + recv/send (test 556) */
   Curl_detach_connection(data);
-  if(data->multi)
-    /* This handle is still part of a multi handle, take care of this first
-       and detach this handle from there. */
-    curl_multi_remove_handle(data->multi, data);
-
-  if(data->multi_easy) {
-    /* when curl_easy_perform() is used, it creates its own multi handle to
-       use and this is the one */
-    curl_multi_cleanup(data->multi_easy);
-    data->multi_easy = NULL;
+  if(!data->internal) {
+    if(data->multi)
+      /* This handle is still part of a multi handle, take care of this first
+         and detach this handle from there. */
+      curl_multi_remove_handle(data->multi, data);
+
+    if(data->multi_easy) {
+      /* when curl_easy_perform() is used, it creates its own multi handle to
+         use and this is the one */
+      curl_multi_cleanup(data->multi_easy);
+      data->multi_easy = NULL;
+    }
   }
 
   data->magic = 0; /* force a clear AFTER the possibly enforced removal from