mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
index: Initialize case_sorted to GIT_VECTOR_INIT
This is for extra safety within write_entries
This commit is contained in:
@@ -2826,7 +2826,7 @@ static int write_entries(git_index *index, git_filebuf *file)
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
git_vector case_sorted, *entries;
|
||||
git_vector case_sorted = GIT_VECTOR_INIT, *entries = NULL;
|
||||
git_index_entry *entry;
|
||||
const char *last = NULL;
|
||||
|
||||
@@ -2834,7 +2834,7 @@ static int write_entries(git_index *index, git_filebuf *file)
|
||||
* to re-sort it case-sensitively before writing */
|
||||
if (index->ignore_case) {
|
||||
if ((error = git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp)) < 0)
|
||||
return error;
|
||||
goto done;
|
||||
|
||||
git_vector_sort(&case_sorted);
|
||||
entries = &case_sorted;
|
||||
@@ -2852,9 +2852,8 @@ static int write_entries(git_index *index, git_filebuf *file)
|
||||
last = entry->path;
|
||||
}
|
||||
|
||||
if (index->ignore_case)
|
||||
git_vector_free(&case_sorted);
|
||||
|
||||
done:
|
||||
git_vector_free(&case_sorted);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user