From: Lennart Poettering Date: Mon, 8 Jan 2024 14:54:42 +0000 (+0100) Subject: bus-polkit: fix memory leak X-Git-Tag: v256-rc1~1237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bcd606815ecfac45177688af42f4907a8ec563b;p=thirdparty%2Fsystemd.git 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 --- 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);