From 4da72644b768b0491110a8ba0aa84d32b6bde41c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C3=85gren?= Date: Tue, 7 Nov 2017 21:39:45 +0100 Subject: reduce_heads: fix memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin/merge.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index ab5ffe85e8..fbbf2a9e5e 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -999,6 +999,7 @@ static struct commit_list *reduce_parents(struct commit *head_commit, /* Find what parents to record by checking independent ones. */ parents = reduce_heads(remoteheads); + free_commit_list(remoteheads); remoteheads = NULL; remotes = &remoteheads; -- cgit v1.2.3