summaryrefslogtreecommitdiff
path: root/builtin/fmt-merge-msg.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-11-07 20:39:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-08 02:34:00 (GMT)
commit4da72644b768b0491110a8ba0aa84d32b6bde41c (patch)
treebe9d8ddc0fc3d78e3d5aa2b80edbf396b7c2b566 /builtin/fmt-merge-msg.c
parenta452d0f4bae99c9acef6f7db75f6f1d922618732 (diff)
downloadgit-4da72644b768b0491110a8ba0aa84d32b6bde41c.zip
git-4da72644b768b0491110a8ba0aa84d32b6bde41c.tar.gz
git-4da72644b768b0491110a8ba0aa84d32b6bde41c.tar.bz2
reduce_heads: fix memory leaks
We currently have seven callers of `reduce_heads(foo)`. Six of them do not use the original list `foo` again, and actually, all six of those end up leaking it. Introduce and use `reduce_heads_replace(&foo)` as a leak-free version of `foo = reduce_heads(foo)` to fix several of these. Fix the remaining leaks using `free_commit_list()`. While we're here, document `reduce_heads()` and mark it as `extern`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fmt-merge-msg.c')
-rw-r--r--builtin/fmt-merge-msg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index e99b5dd..27a2361 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -571,7 +571,7 @@ static void find_merge_parents(struct merge_parents *result,
head_commit = lookup_commit(head);
if (head_commit)
commit_list_insert(head_commit, &parents);
- parents = reduce_heads(parents);
+ reduce_heads_replace(&parents);
while (parents) {
struct commit *cmit = pop_commit(&parents);