]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect: fix leaking commit list items in `check_merge_base()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 20 Nov 2024 13:39:35 +0000 (14:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:23:41 +0000 (08:23 +0900)
While we free the result commit list at the end of `check_merge_base()`,
we forget to free any items that we have already iterated over. Fix this
by using a separate variable to iterate through them.

This leak is exposed by t6030, but plugging it does not make the whole
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bisect.c

index 04e9a63f11c7fa1a9dd11d3f193c500a4cb937c6..12efcff2e3c1836ab6e63d36e4d42269fbcaeaab 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -851,8 +851,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
                                      rev + 1, &result) < 0)
                exit(128);
 
-       for (; result; result = result->next) {
-               const struct object_id *mb = &result->item->object.oid;
+       for (struct commit_list *l = result; l; l = l->next) {
+               const struct object_id *mb = &l->item->object.oid;
                if (oideq(mb, current_bad_oid)) {
                        res = handle_bad_merge_base();
                        break;