aboutsummaryrefslogtreecommitdiffstats
path: root/revision.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-26 13:47:05 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-27 08:25:37 -0700
commitfa016423c748cd142a40c10eb7f9cc4c4fffbb98 (patch)
tree24deafaad2b7051a396b5f97c1db619d1108d1dd /revision.c
parentbuiltin/maintenance: fix leak in `get_schedule_cmd()` (diff)
downloadgit-fa016423c748cd142a40c10eb7f9cc4c4fffbb98.tar.gz
git-fa016423c748cd142a40c10eb7f9cc4c4fffbb98.zip
revision: fix leaking parents when simplifying commits
When simplifying commits, e.g. because they are treesame with their parents, we unset the commit's parent pointers but never free them. Plug the resulting memory leaks. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/revision.c b/revision.c
index 2d7ad2bddf..e79f39e555 100644
--- a/revision.c
+++ b/revision.c
@@ -1071,7 +1071,11 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
ts->treesame[nth_parent] = 1;
continue;
}
+
+ free_commit_list(parent->next);
parent->next = NULL;
+ while (commit->parents != parent)
+ pop_commit(&commit->parents);
commit->parents = parent;
/*
@@ -1103,6 +1107,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
die("cannot simplify commit %s (invalid %s)",
oid_to_hex(&commit->object.oid),
oid_to_hex(&p->object.oid));
+ free_commit_list(p->parents);
p->parents = NULL;
}
/* fallthrough */