Skip to content

Commit 1a2d8bd

Browse files
committed
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 parent 661db4f commit 1a2d8bd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GIT_INLINE(int) git_array__search(
9696
{
9797
size_t lim;
9898
unsigned char *part, *array = array_ptr, *base = array_ptr;
99-
int cmp;
99+
int cmp = -1;
100100

101101
for (lim = array_len; lim != 0; lim >>= 1) {
102102
part = base + (lim >> 1) * item_size;

0 commit comments

Comments
 (0)