diff mbox series

[06/26] bisect: fix leaking commit list items in `check_merge_base()`

Message ID fba5b4b9f60c4d22aacb2c66ac96fefe6fd8f5fd.1730901926.git.ps@pks.im (mailing list archive)
State New
Headers show
Series [01/26] builtin/blame: fix leaking blame entries with `--incremental` | expand

Commit Message

Patrick Steinhardt Nov. 6, 2024, 3:10 p.m. UTC
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>
---
 bisect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/bisect.c b/bisect.c
index 04e9a63f11c..12efcff2e3c 100644
--- 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;