From 32b8166150c39f4d68b64b0483d6723dfc35bc10 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sat, 20 Oct 2018 20:16:32 +0100 Subject: merge: don't leak the index during reloads --- src/merge.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/merge.c b/src/merge.c index 5eb98848e..ade0d60d3 100644 --- a/src/merge.c +++ b/src/merge.c @@ -3232,7 +3232,7 @@ int git_merge( git_reference *our_ref = NULL; git_checkout_options checkout_opts; git_annotated_commit *our_head = NULL, *base = NULL; - git_index *index = NULL; + git_index *repo_index = NULL, *index = NULL; git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; unsigned int checkout_strategy; int error = 0; @@ -3255,8 +3255,8 @@ int git_merge( &checkout_strategy)) < 0) goto done; - if ((error = git_repository_index(&index, repo) < 0) || - (error = git_index_read(index, 0) < 0)) + if ((error = git_repository_index(&repo_index, repo) < 0) || + (error = git_index_read(repo_index, 0) < 0)) goto done; /* Write the merge setup files to the repository. */ @@ -3292,6 +3292,7 @@ done: git_annotated_commit_free(our_head); git_annotated_commit_free(base); git_reference_free(our_ref); + git_index_free(repo_index); return error; } -- cgit v1.2.1