Patrick Steinhardt <ps@xxxxxx> writes: > On Wed, Jun 04, 2025 at 03:08:56AM +0000, Lidong Yan via GitGitGadget wrote: >> From: Lidong Yan <502024330056@xxxxxxxxxxxxxxxx> >> >> In revision.c:prepare_show_merge(), we allocated an array in prune >> but forget to free it. Since parse_pathspec is not responsible to >> free prune, we should add `free(prune)` in the end of prepare_show_merge(). > > That is a rather obvious memory leak indeed. Do you know why we never > detected the leak in our CI? Is this code path not exercised at all by > our tests? I think we have no "show --merge" test. Something like this may be minimally sufficient. t/t7007-show.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git c/t/t7007-show.sh w/t/t7007-show.sh index d6cc69e0f2..99f4d0b963 100755 --- c/t/t7007-show.sh +++ w/t/t7007-show.sh @@ -167,4 +167,19 @@ test_expect_success 'show --graph is forbidden' ' test_must_fail git show --graph HEAD ' +test_expect_success 'unmerged index' ' + git reset --hard && + git commit --allow-empty -m initial && + git rev-parse HEAD >.git/MERGE_HEAD && + blob1=$(echo hello | git hash-object -w --stdin) && + blob2=$(echo goodbye | git hash-object -w --stdin) && + blob3=$(echo world | git hash-object -w --stdin) && + git update-index --add --index-info <<-EOF && + 100644 $blob1 1 conflicting + 100644 $blob2 2 conflicting + 100755 $blob3 3 conflicting + EOF + git show --merge HEAD +' + test_done