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:
Tobias Brunner 2020-01-28 11:06:59 +01:00
parent 73ee7b6664
commit 7bcbf20b3d
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}