Unverified Commit 0fb58396 by Edward Thomson Committed by GitHub

Merge pull request #5801 from mamapanda/patch-1

index: Check git_vector_dup error in write_entries
parents 6e57010b 40930508
......@@ -2861,14 +2861,16 @@ 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;
/* If index->entries is sorted case-insensitively, then we need
* to re-sort it case-sensitively before writing */
if (index->ignore_case) {
git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp);
if ((error = git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp)) < 0)
goto done;
git_vector_sort(&case_sorted);
entries = &case_sorted;
} else {
......@@ -2885,9 +2887,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