]> git.ipfire.org Git - thirdparty/git.git/commit
fsmonitor: fix khash memory leak in do_handle_client
authorPaul Tarjan <github@paulisageek.com>
Wed, 15 Apr 2026 13:27:26 +0000 (13:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Apr 2026 15:44:32 +0000 (08:44 -0700)
commite21be6cd45db554862f40c90b385c1bc465c8335
tree65ccebe6710d997a773d2c18cd73ae436c6b7d2e
parent7cce609e086866d054a1433d0356fa71e55c108d
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