mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
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:
parent
bce073dca1
commit
a57f0b190a
@ -1068,6 +1068,7 @@ g_array_maybe_expand (GRealArray *array,
|
|||||||
if (want_len > array->elt_capacity)
|
if (want_len > array->elt_capacity)
|
||||||
{
|
{
|
||||||
gsize want_alloc = g_nearest_pow (g_array_elt_len (array, want_len));
|
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);
|
want_alloc = MAX (want_alloc, MIN_ARRAY_SIZE);
|
||||||
|
|
||||||
array->data = g_realloc (array->data, want_alloc);
|
array->data = g_realloc (array->data, want_alloc);
|
||||||
|
Loading…
Reference in New Issue
Block a user