]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: DnsTransaction.scope may be NULL when dns_transaction_close_connection(...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 29 Dec 2023 20:35:32 +0000 (05:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 30 Dec 2023 19:51:59 +0000 (04:51 +0900)
Follow-up for ac1b7b9e1933c14bc7bf36d4f32a888afb3f2f4d.

Fixes CID#1533020.

src/resolve/resolved-dns-transaction.c

index d44315ab1e63213448edc1bdf49103d2aae121dc..e4a1a29071c2a44a62b9a000dbf8a4aab6456ef4 100644 (file)
@@ -74,8 +74,12 @@ static void dns_transaction_close_connection(
          * and the reply we might still get from the server will be eaten up instead of resulting in an ICMP
          * port unreachable error message. */
 
-        /* Skip the graveyard stuff when we're shutting down, since that requires running event loop */
-        if (!t->scope->manager->event || sd_event_get_state(t->scope->manager->event) == SD_EVENT_FINISHED)
+        /* Skip the graveyard stuff when we're shutting down, since that requires running event loop.
+         * Note that this is also called from dns_transaction_free(). In that case, scope may be NULL. */
+        if (!t->scope ||
+            !t->scope->manager ||
+            !t->scope->manager->event ||
+            sd_event_get_state(t->scope->manager->event) == SD_EVENT_FINISHED)
                 use_graveyard = false;
 
         if (use_graveyard && t->dns_udp_fd >= 0 && t->sent && !t->received) {