Commit 1a2d8bd3c2b0f20e69b295c638b0e0c44c216756

Carlos Martín Nieto 2016-03-23T16:51:52

array: fix search for empty arrays When the array is empty `cmp` never gets set by the comparison function. Initialize it so we return ENOTFOUND in those cases.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/array.h b/src/array.h
index 490e6be..78d321e 100644
--- a/src/array.h
+++ b/src/array.h
@@ -96,7 +96,7 @@ GIT_INLINE(int) git_array__search(
 {
 	size_t lim;
 	unsigned char *part, *array = array_ptr, *base = array_ptr;
-	int cmp;
+	int cmp = -1;
 
 	for (lim = array_len; lim != 0; lim >>= 1) {
 		part = base + (lim >> 1) * item_size;