Subject: [PATCH v6 02/10] fsmonitor: fix hashmap memory leak in fsmonitor_run_daemon

From: "Paul Tarjan via GitGitGadget" <[email-masked]>
Date: Wed, 25 Feb 2026 20:17:08 +0000

From: Paul Tarjan <[email-masked]>

The `state.cookies` hashmap is initialized during daemon startup but
never freed during cleanup in the `done:` label of
fsmonitor_run_daemon().  Add a hashmap_clear() call to prevent this
memory leak.

Signed-off-by: Paul Tarjan <[email-masked]>
---
 builtin/fsmonitor--daemon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index bc4571938c..4d52622e24 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1404,6 +1404,7 @@ static int fsmonitor_run_daemon(void)
 done:
 	pthread_cond_destroy(&state.cookies_cond);
 	pthread_mutex_destroy(&state.main_lock);
+	hashmap_clear(&state.cookies);
 	fsm_listen__dtor(&state);
 	fsm_health__dtor(&state);
 
-- 
gitgitgadget