]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: fix transaction leak in dns_transaction_new() error path
authordongshengyuan <545258830@qq.com>
Mon, 22 Jun 2026 06:13:11 +0000 (14:13 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 22 Jun 2026 10:21:47 +0000 (11:21 +0100)
hashmap_replace() failure left t in s->manager->dns_transactions with
t->scope still NULL, causing the destructor to skip hashmap_remove().
Add the missing cleanup mirroring the earlier error path in the same
function.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
src/resolve/resolved-dns-transaction.c

index a14aa0de7dbf609fc1cb66d92cdce516c340afcc..cbfe24ee7e895cc5220a7b06193f090a4405b4b9 100644 (file)
@@ -326,6 +326,8 @@ int dns_transaction_new(
                 r = hashmap_replace(s->transactions_by_key, first->key, first);
                 if (r < 0) {
                         LIST_REMOVE(transactions_by_key, first, t);
+                        hashmap_remove(s->manager->dns_transactions, UINT_TO_PTR(t->id));
+                        t->id = 0;
                         return r;
                 }
         }