Commit e0afd1c21c4421cec4f67162021f835e2bbb7df6

Etienne Samson 2018-09-26T21:17:39

vector: do not realloc 0-size vectors

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/vector.c b/src/vector.c
index aac4863..98aa7bb 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -32,6 +32,9 @@ GIT_INLINE(int) resize_vector(git_vector *v, size_t new_size)
 {
 	void *new_contents;
 
+	if (new_size == 0)
+		return 0;
+
 	new_contents = git__reallocarray(v->contents, new_size, sizeof(void *));
 	GITERR_CHECK_ALLOC(new_contents);