Fix ubsan with passing nullptr to qsort()
This commit is contained in:
parent
357a0a7ad3
commit
89949ed28d
@ -119,11 +119,13 @@ struct hb_array_t :
|
|||||||
|
|
||||||
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*))
|
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*))
|
||||||
{
|
{
|
||||||
|
if (likely (length))
|
||||||
::qsort (arrayZ, length, this->item_size, cmp_);
|
::qsort (arrayZ, length, this->item_size, cmp_);
|
||||||
return hb_sorted_array_t<Type> (*this);
|
return hb_sorted_array_t<Type> (*this);
|
||||||
}
|
}
|
||||||
hb_sorted_array_t<Type> qsort ()
|
hb_sorted_array_t<Type> qsort ()
|
||||||
{
|
{
|
||||||
|
if (likely (length))
|
||||||
::qsort (arrayZ, length, this->item_size, Type::cmp);
|
::qsort (arrayZ, length, this->item_size, Type::cmp);
|
||||||
return hb_sorted_array_t<Type> (*this);
|
return hb_sorted_array_t<Type> (*this);
|
||||||
}
|
}
|
||||||
@ -131,6 +133,7 @@ struct hb_array_t :
|
|||||||
{
|
{
|
||||||
end = MIN (end, length);
|
end = MIN (end, length);
|
||||||
assert (start <= end);
|
assert (start <= end);
|
||||||
|
if (likely (start < end))
|
||||||
::qsort (arrayZ + start, end - start, this->item_size, Type::cmp);
|
::qsort (arrayZ + start, end - start, this->item_size, Type::cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user