From a57f0b190acfed848a041ee7e4cd125ce9c2f149 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 12 Apr 2023 21:10:21 +0200 Subject: [PATCH] array: Abort on overflow This is a precautionary assert that will probably only trigger on 32bit OSes. But g_nearest_pow() can overflow. --- glib/garray.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/garray.c b/glib/garray.c index efd031b0c..e586bb5fa 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -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);