From 4bcd606815ecfac45177688af42f4907a8ec563b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jan 2024 15:54:42 +0100 Subject: [PATCH] bus-polkit: fix memory leak We need to destroy the hashmap entry keyed by the varlink object in case this is a varlink request. Follow-up for: d04c1a1c8e7c95daa483d8d52d5fc4c25fbc67f2 --- src/shared/bus-polkit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c index fe9363aad44..ff905d147f8 100644 --- a/src/shared/bus-polkit.c +++ b/src/shared/bus-polkit.c @@ -192,9 +192,9 @@ typedef struct AsyncPolkitQuery { AsyncPolkitQueryAction *action; sd_bus *bus; - sd_bus_message *request; + sd_bus_message *request; /* the original bus method call that triggered the polkit auth, NULL in case of varlink */ sd_bus_slot *slot; - Varlink *link; + Varlink *link; /* the original varlink method call that triggered the polkit auth, NULL in case of bus */ Hashmap *registry; sd_event_source *defer_event_source; @@ -211,8 +211,12 @@ static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) { sd_bus_slot_unref(q->slot); - if (q->registry && q->request) - hashmap_remove(q->registry, q->request); + if (q->registry) { + if (q->request) + hashmap_remove(q->registry, q->request); + if (q->link) + hashmap_remove(q->registry, q->link); + } sd_bus_message_unref(q->request); -- 2.47.3