Commit 74e06c05b54856e31009b8cbb54ea735ee439381

Vicent Martí 2013-11-05T08:32:09

Merge pull request #1945 from libgit2/ntk/fix/merge_leaks Plug git_merge() related leaks

diff --git a/src/merge.c b/src/merge.c
index 973d444..2cbf531 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2451,6 +2451,7 @@ int git_merge(
 on_error:
 	git_repository_merge_cleanup(repo);
 
+	git_index_free(index_new);
 	git__free(result);
 
 done:
diff --git a/tests-clar/merge/workdir/setup.c b/tests-clar/merge/workdir/setup.c
index 511106a..463dee0 100644
--- a/tests-clar/merge/workdir/setup.c
+++ b/tests-clar/merge/workdir/setup.c
@@ -1019,6 +1019,7 @@ void test_merge_workdir_setup__retained_after_success(void)
 
 	git_merge_head_free(our_head);
 	git_merge_head_free(their_heads[0]);
+	git_merge_result_free(result);
 }
 
 void test_merge_workdir_setup__removed_after_failure(void)
@@ -1051,4 +1052,5 @@ void test_merge_workdir_setup__removed_after_failure(void)
 
 	git_merge_head_free(our_head);
 	git_merge_head_free(their_heads[0]);
+	git_merge_result_free(result);
 }