]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/notes: fix leaking `struct notes_tree` when merging notes
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:20 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:07:59 +0000 (10:07 -0700)
commit187b623eeff215b56d8e45ebab1de899e974383a
tree38e82933b8899238177c0b51f55f6bbe0eec344b
parent1ca57bea4a8a4637c4e7d2a2f46677acc4795d81
builtin/notes: fix leaking `struct notes_tree` when merging notes

We allocate a `struct notes_tree` in `merge_commit()` which we then
initialize via `init_notes()`. It's not really necessary to allocate the
structure though given that we never pass ownership to the caller.
Furthermore, the allocation leads to a memory leak because despite its
name, `free_notes()` doesn't free the `notes_tree` but only clears it.

Fix this issue by converting the code to use an on-stack variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/notes.c
t/t3310-notes-merge-manual-resolve.sh
t/t3311-notes-merge-fanout.sh