Commit 7f1dd445 by panda Committed by Edward Thomson

index: Initialize case_sorted to GIT_VECTOR_INIT

This is for extra safety within write_entries
parent f4c05192
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment