summaryrefslogtreecommitdiff
path: root/builtin/pull.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-11-07 21:39:45 +0100
committerJunio C Hamano <gitster@pobox.com>2017-11-08 11:34:00 +0900
commit4da72644b768b0491110a8ba0aa84d32b6bde41c (patch)
treebe9d8ddc0fc3d78e3d5aa2b80edbf396b7c2b566 /builtin/pull.c
parenta452d0f4bae99c9acef6f7db75f6f1d922618732 (diff)
downloadgit-4da72644b768b0491110a8ba0aa84d32b6bde41c.tar.gz
reduce_heads: fix memory leaksma/reduce-heads-leakfix
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/pull.c')
-rw-r--r--builtin/pull.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 6f772e8a22..4edab228eb 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -745,12 +745,15 @@ static int get_octopus_merge_base(struct object_id *merge_base,
if (!is_null_oid(fork_point))
commit_list_insert(lookup_commit_reference(fork_point), &revs);
- result = reduce_heads(get_octopus_merge_bases(revs));
+ result = get_octopus_merge_bases(revs);
free_commit_list(revs);
+ reduce_heads_replace(&result);
+
if (!result)
return 1;
oidcpy(merge_base, &result->item->object.oid);
+ free_commit_list(result);
return 0;
}