diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 20:16:32 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 20:16:32 +0100 |
commit | 32b8166150c39f4d68b64b0483d6723dfc35bc10 (patch) | |
tree | f3ac61f3006a256584e3ac7161d2eb43eb326b66 | |
parent | e8d373c4feb9cddc9cc2e50e2f486bc7ef6bcf9c (diff) | |
download | libgit2-32b8166150c39f4d68b64b0483d6723dfc35bc10.tar.gz |
merge: don't leak the index during reloadsethomson/issue-4203
-rw-r--r-- | src/merge.c | 7 |
1 files 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; } |