]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-reach: free temporary list in get_octopus_merge_bases()
authorJeff King <peff@peff.net>
Tue, 3 Oct 2023 20:26:30 +0000 (16:26 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Oct 2023 21:28:23 +0000 (14:28 -0700)
We loop over the set of commits to merge, and for each one compute the
merge base against the existing set of merge base candidates we've
found. Then we replace the candidate set with a simple assignment of the
list head, leaking the old list. We should free it first before
assignment.

This makes t5521 leak-free, so mark it as such.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-reach.c
t/t5521-pull-options.sh

index 4b7c233fd468f9ad2a60abf5b9202f5c4fbad3c4..a868a575ea1cf8e7ccd331610b9d309a065ad135 100644 (file)
@@ -173,6 +173,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
                        for (k = bases; k; k = k->next)
                                end = k;
                }
+               free_commit_list(ret);
                ret = new_commits;
        }
        return ret;
index 264de29c35c11cbe09d31d57629aabaae0423b35..079b2f2536e6974c90b152226d8ea2189016a6f6 100755 (executable)
@@ -5,6 +5,7 @@ test_description='pull options'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '