From 44ec7c575f914d77787a17cefd094e3c46b8b12b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 11 Jun 2024 11:21:11 +0200 Subject: merge: fix leaking merge bases When calling either the recursive or the ORT merge machineries we need to provide a list of merge bases. The ownership of that parameter is then implicitly transferred to the callee, which is somewhat fishy. Furthermore, that list may leak in some cases where the merge machinery runs into an error, thus causing a memory leak. Refactor the code such that we stop transferring ownership. Instead, the merge machinery will now create its own local copies of the passed in list as required if they need to modify the list. Free the list at the callsites as required. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- log-tree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'log-tree.c') diff --git a/log-tree.c b/log-tree.c index 41416de4e3..91b96d83a0 100644 --- a/log-tree.c +++ b/log-tree.c @@ -1047,6 +1047,7 @@ static int do_remerge_diff(struct rev_info *opt, log_tree_diff_flush(opt); /* Cleanup */ + free_commit_list(bases); cleanup_additional_headers(&opt->diffopt); strbuf_release(&parent1_desc); strbuf_release(&parent2_desc); -- cgit v1.2.3