diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2016-03-23 16:51:52 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2016-03-23 16:51:52 +0100 |
commit | 1a2d8bd3c2b0f20e69b295c638b0e0c44c216756 (patch) | |
tree | 75ea988ffd0089ff93e4ff512b736a1e2d06962d /src/array.h | |
parent | 661db4f4829a0fe1330f275de6e58c34589f512f (diff) | |
download | libgit2-1a2d8bd3c2b0f20e69b295c638b0e0c44c216756.tar.gz |
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.
Diffstat (limited to 'src/array.h')
-rw-r--r-- | src/array.h | 2 |
1 files changed, 1 insertions, 1 deletions
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; |