]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
asyn-ares: handle no connection in the addrinfo callback
authorDaniel Stenberg <daniel@haxx.se>
Fri, 27 Oct 2023 22:22:49 +0000 (00:22 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 28 Oct 2023 08:46:06 +0000 (10:46 +0200)
To avoid crashing.

Follow-up from 56a4db2
Closes #12219

lib/asyn-ares.c

index 1da190127811be430fb9d532f0fdf03406371209..764eadbfcfe75f3a2552a49501d8d2c768dae2dc 100644 (file)
@@ -729,14 +729,16 @@ static void addrinfo_cb(void *arg, int status, int timeouts,
                         struct ares_addrinfo *result)
 {
   struct Curl_easy *data = (struct Curl_easy *)arg;
-  struct thread_data *res = data->conn->resolve_async.tdata;
-  (void)timeouts;
-  if(ARES_SUCCESS == status) {
-    res->temp_ai = ares2addr(result->nodes);
-    res->last_status = CURL_ASYNC_SUCCESS;
-    ares_freeaddrinfo(result);
+  if(data->conn) {
+    struct thread_data *res = data->conn->resolve_async.tdata;
+    (void)timeouts;
+    if(ARES_SUCCESS == status) {
+      res->temp_ai = ares2addr(result->nodes);
+      res->last_status = CURL_ASYNC_SUCCESS;
+      ares_freeaddrinfo(result);
+    }
+    res->num_pending--;
   }
-  res->num_pending--;
 }
 
 #endif