]> git.ipfire.org Git - thirdparty/git.git/commit
match-trees: fix leaking prefixes in `shift_tree()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:09:36 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:12 +0000 (08:49 -0700)
commit2a0147089151e3dd2cc8e6c91ecaf45fb416630e
treec785edacde8afbf34fb02e56caccdf19e243f3be
parent68bd0a94bedf520bc67ca38216e839770f291296
match-trees: fix leaking prefixes in `shift_tree()`

In `shift_tree()` we allocate two empty strings that we end up
passing to `match_trees()`. If that function finds a better match it
will update these pointers to point to a newly allocated strings,
freeing the old strings. We never free the final results though, neither
the ones we have allocated ourselves, nor the one that `match_trees()`
might've returned to us.

Fix the resulting memory leaks by creating a common exit path where we
free them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
match-trees.c
t/t6409-merge-subtree.sh