Skip to content

Commit 0abb962

Browse files
committed
Merge branch 'nd/repo-clear-keep-the-index'
the_repository->index is not a allocated piece of memory but repo_clear() indiscriminately attempted to free(3) it, which has been corrected. * nd/repo-clear-keep-the-index: repository: fix free problem with repo_clear(the_repository)
2 parents 2f76ebc + 74373b5 commit 0abb962

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

repository.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ void repo_clear(struct repository *repo)
238238

239239
if (repo->index) {
240240
discard_index(repo->index);
241-
FREE_AND_NULL(repo->index);
241+
if (repo->index != &the_index)
242+
FREE_AND_NULL(repo->index);
242243
}
243244
}
244245

0 commit comments

Comments
 (0)