Commit adfece0d by Carlos Martín Nieto

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.
parent 5a9d850e
...@@ -96,7 +96,7 @@ GIT_INLINE(int) git_array__search( ...@@ -96,7 +96,7 @@ GIT_INLINE(int) git_array__search(
{ {
size_t lim; size_t lim;
unsigned char *part, *array = array_ptr, *base = array_ptr; unsigned char *part, *array = array_ptr, *base = array_ptr;
int cmp; int cmp = -1;
for (lim = array_len; lim != 0; lim >>= 1) { for (lim = array_len; lim != 0; lim >>= 1) {
part = base + (lim >> 1) * item_size; part = base + (lim >> 1) * item_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment