Skip to content

Commit 21981f2

Browse files
committed
index: Check git_vector_dup error in write_entries
If allocating case_sorted.contents fails, git_vector_sort will segfault.
1 parent 935f851 commit 21981f2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,9 @@ static int write_entries(git_index *index, git_filebuf *file)
28682868
/* If index->entries is sorted case-insensitively, then we need
28692869
* to re-sort it case-sensitively before writing */
28702870
if (index->ignore_case) {
2871-
git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp);
2871+
if ((error = git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp)) < 0)
2872+
return error;
2873+
28722874
git_vector_sort(&case_sorted);
28732875
entries = &case_sorted;
28742876
} else {

0 commit comments

Comments
 (0)