array: Avoid overflow in size calculation
While it's unlikely that so many (large) items are allocated, this is technically more correct. The result previously could overflow an unsigned int (the conversion to size_t happened afterwards).
This commit is contained in:
parent
73ee7b6664
commit
7bcbf20b3d
|
@ -68,7 +68,7 @@ static size_t get_size(array_t *array, uint32_t num)
|
|||
{
|
||||
if (array->esize)
|
||||
{
|
||||
return array->esize * num;
|
||||
return (size_t)array->esize * num;
|
||||
}
|
||||
return sizeof(void*) * num;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue