summaryrefslogtreecommitdiffstats
path: root/merge-ort-wrappers.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-11 11:21:11 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-11 22:15:08 +0200
commit44ec7c575f914d77787a17cefd094e3c46b8b12b (patch)
tree185a726b608127146430586f18dcdbb77f981372 /merge-ort-wrappers.c
parentbuiltin/merge: fix leaking `struct cmdnames` in `get_strategy()` (diff)
downloadgit-44ec7c575f914d77787a17cefd094e3c46b8b12b.tar.xz
git-44ec7c575f914d77787a17cefd094e3c46b8b12b.zip
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort-wrappers.c')
-rw-r--r--merge-ort-wrappers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index 4acedf3c33..d6f6135996 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -48,7 +48,7 @@ int merge_ort_nonrecursive(struct merge_options *opt,
int merge_ort_recursive(struct merge_options *opt,
struct commit *side1,
struct commit *side2,
- struct commit_list *merge_bases,
+ const struct commit_list *merge_bases,
struct commit **result)
{
struct tree *head = repo_get_commit_tree(opt->repo, side1);