merge: free result of repo_get_merge_bases()
commit716a6b2c3a54779e1e6f115a5950511d019f4d17
authorJeff King <peff@peff.net>
Tue, 3 Oct 2023 20:27:24 +0000 (3 16:27 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Oct 2023 21:28:24 +0000 (3 14:28 -0700)
tree0536ae9ead3e6b9cf8a93faba8274d616a94d45a
parentec97ad120caad0c7366a19a6680d37e2b8c5107c
merge: free result of repo_get_merge_bases()

We call repo_get_merge_bases(), which allocates a commit_list, but never
free the result, causing a leak.

The obvious solution is to free it, but we need to look at the contents
of the first item to decide whether to leave the loop. One option is to
free it in both code paths. But since the commit that the list points to
is longer-lived than the list itself, we can just dereference it
immediately, free the list, and then continue with the existing logic.
This is about the same amount of code, but keeps the list management all
in one place.

This lets us mark a number of merge-related test scripts as leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c
t/t4214-log-graph-octopus.sh
t/t4215-log-skewed-merges.sh
t/t6009-rev-list-parent.sh
t/t6416-recursive-corner-cases.sh
t/t6433-merge-toplevel.sh
t/t6437-submodule-merge.sh
t/t7602-merge-octopus-many.sh
t/t7603-merge-reduce-heads.sh
t/t7607-merge-state.sh
t/t7608-merge-messages.sh