]> git.ipfire.org Git - thirdparty/git.git/commit
fsmonitor: fix khash memory leak in do_handle_client
authorPaul Tarjan <github@paulisageek.com>
Thu, 9 Apr 2026 04:59:24 +0000 (04:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Apr 2026 17:59:27 +0000 (10:59 -0700)
commitc0901a7cd11b27e22a120f81a2bb4d44f3428a02
tree65ccebe6710d997a773d2c18cd73ae436c6b7d2e
parent7ab80e63898de69e9b61ada62de5315e021850ec
fsmonitor: fix khash memory leak in do_handle_client

The `shown` kh_str_t was freed with kh_release_str() at a point in
the code only reachable in the non-trivial response path.  When the
client receives a trivial response, the code jumps to the `cleanup`
label, skipping the kh_release_str() call entirely and leaking the
hash table.

Fix this by initializing `shown` to NULL and moving the cleanup to the
`cleanup` label using kh_destroy_str(), which is safe to call on NULL.
This ensures the hash table is freed regardless of which code path is
taken.

Signed-off-by: Paul Tarjan <github@paulisageek.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fsmonitor--daemon.c