Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-11-07 23:39:45 +0300
committerJunio C Hamano <gitster@pobox.com>2017-11-08 05:34:00 +0300
commit4da72644b768b0491110a8ba0aa84d32b6bde41c (patch)
treebe9d8ddc0fc3d78e3d5aa2b80edbf396b7c2b566 /builtin/merge-base.c
parenta452d0f4bae99c9acef6f7db75f6f1d922618732 (diff)
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/merge-base.c')
-rw-r--r--builtin/merge-base.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index e17835fabb..24f6c71935 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -57,7 +57,7 @@ static int handle_independent(int count, const char **args)
for (i = count - 1; i >= 0; i--)
commit_list_insert(get_commit_reference(args[i]), &revs);
- revs = reduce_heads(revs);
+ reduce_heads_replace(&revs);
if (!revs)
return 1;
@@ -78,7 +78,9 @@ static int handle_octopus(int count, const char **args, int show_all)
for (i = count - 1; i >= 0; i--)
commit_list_insert(get_commit_reference(args[i]), &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;