Skip to content

Commit 32b8166

Browse files
committed
merge: don't leak the index during reloads
1 parent e8d373c commit 32b8166

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/merge.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,7 @@ int git_merge(
32323232
git_reference *our_ref = NULL;
32333233
git_checkout_options checkout_opts;
32343234
git_annotated_commit *our_head = NULL, *base = NULL;
3235-
git_index *index = NULL;
3235+
git_index *repo_index = NULL, *index = NULL;
32363236
git_indexwriter indexwriter = GIT_INDEXWRITER_INIT;
32373237
unsigned int checkout_strategy;
32383238
int error = 0;
@@ -3255,8 +3255,8 @@ int git_merge(
32553255
&checkout_strategy)) < 0)
32563256
goto done;
32573257

3258-
if ((error = git_repository_index(&index, repo) < 0) ||
3259-
(error = git_index_read(index, 0) < 0))
3258+
if ((error = git_repository_index(&repo_index, repo) < 0) ||
3259+
(error = git_index_read(repo_index, 0) < 0))
32603260
goto done;
32613261

32623262
/* Write the merge setup files to the repository. */
@@ -3292,6 +3292,7 @@ int git_merge(
32923292
git_annotated_commit_free(our_head);
32933293
git_annotated_commit_free(base);
32943294
git_reference_free(our_ref);
3295+
git_index_free(repo_index);
32953296

32963297
return error;
32973298
}

0 commit comments

Comments
 (0)