Ensured calls to bsearch() have a length of at least 1; UndefinedBehaviorSanitizer will warn otherwise. Also included qsort(), to be safe.
This commit is contained in:
parent
6d6cd66046
commit
12c01d0d42
|
@ -77,11 +77,14 @@ void sharedbitsPrefixName(ArrayDeleteItem)(sharedbitsPrefixName(Array) *arr, voi
|
||||||
|
|
||||||
void *sharedbitsPrefixName(ArrayBsearch)(const sharedbitsPrefixName(Array) *arr, const void *key, int (*compare)(const void *, const void *))
|
void *sharedbitsPrefixName(ArrayBsearch)(const sharedbitsPrefixName(Array) *arr, const void *key, int (*compare)(const void *, const void *))
|
||||||
{
|
{
|
||||||
|
if (arr->len == 0)
|
||||||
|
return NULL;
|
||||||
return bsearch(key, arr->buf, arr->len, arr->elemsize, compare);
|
return bsearch(key, arr->buf, arr->len, arr->elemsize, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sharedbitsPrefixName(ArrayQsort)(sharedbitsPrefixName(Array) *arr, int (*compare)(const void *, const void *))
|
void sharedbitsPrefixName(ArrayQsort)(sharedbitsPrefixName(Array) *arr, int (*compare)(const void *, const void *))
|
||||||
{
|
{
|
||||||
|
if (arr->len != 0)
|
||||||
qsort(arr->buf, arr->len, arr->elemsize, compare);
|
qsort(arr->buf, arr->len, arr->elemsize, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue