From adfece0df2153234970ded1b0552c5150e7f0c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 23 Mar 2016 16:51:52 +0100 Subject: 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. --- src/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array.h b/src/array.h index 490e6be20..78d321e82 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; -- cgit v1.2.1