Re: [PATCH v2] fsmonitor: fix khash memory leak in do_handle_client
- From
- Paul Tarjan <paul@paultarjan.com>
- Date
- Jan 2, 2026, 01:24 UTC
- Message-ID
- <CALvWuB6MW8g3Vd1-gKkZa_r86o0-t3gGazLSvsoBO4m6jjubeQ@mail.gmail.com>
- In-Reply-To
- <xmqqbjjdc4d0.fsf@gitster.g>
On Thu, Jan 1, 2026 at 1:14 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> > "Paul Tarjan via GitGitGadget" <gitgitgadget@gmail.com> writes: > > > From: Paul Tarjan <github@paulisageek.com> > > > > The do_handle_client() function allocates a khash table to de-duplicate > > pathnames when responding to client requests. However, kh_release_str() > > was used instead of kh_destroy_str(). The release function only frees > > internal arrays (flags, keys, vals) but not the struct itself, which is > > allocated by kh_init_str() via xcalloc. This caused a 40-byte leak per > > client request. > > > > Fix by using kh_destroy_str() which properly frees both internal arrays > > and the struct itself. Also move the cleanup to the cleanup section and > > initialize shown to NULL so that kh_destroy_str() is safe to call on all > > exit paths. > > > > Signed-off-by: Paul Tarjan <github@paulisageek.com> > > --- > > This is already in v4 of the other larger fsmonitor-linux patch, > right?
Correct. I sent it separately since it is currently a bug in existing code and you might want to merge it sooner.
> > Thanks. >