array: Abort on overflow

This is a precautionary assert that will probably only trigger on 32bit
OSes. But g_nearest_pow() can overflow.
This commit is contained in:
Benjamin Otte 2023-04-12 21:10:21 +02:00 committed by Philip Withnall
parent bce073dca1
commit a57f0b190a

View File

@ -1068,6 +1068,7 @@ g_array_maybe_expand (GRealArray *array,
if (want_len > array->elt_capacity)
{
gsize want_alloc = g_nearest_pow (g_array_elt_len (array, want_len));
g_assert (want_alloc >= g_array_elt_len (array, want_len));
want_alloc = MAX (want_alloc, MIN_ARRAY_SIZE);
array->data = g_realloc (array->data, want_alloc);