From 4bc794e42acdd2bfad6c29dfdd098eb35c20bb1e Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Wed, 20 Aug 2025 20:09:31 +0200 Subject: [PATCH] ghash: Handle hash tables with millions of entries Multiplying a guint value with BIG_ENTRY_SIZE (8) can overflow the guint data type if size reaches 2^29. Use the correct size_t type for 64 bit systems to support such allocations. A 32 bit system should fail its reallocation way earlier before reaching such a large "size", i.e. item count, especially when reallocating. Also, it would multiply with 4. Closes #3724 --- glib/ghash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/ghash.c b/glib/ghash.c index d8e81b22a..82b750689 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -323,7 +323,7 @@ g_hash_table_set_shift_from_size (GHashTable *hash_table, gint size) } static inline gpointer -g_hash_table_realloc_key_or_value_array (gpointer a, guint size, G_GNUC_UNUSED gboolean is_big) +g_hash_table_realloc_key_or_value_array (gpointer a, size_t size, G_GNUC_UNUSED gboolean is_big) { #ifdef USE_SMALL_ARRAYS return g_realloc (a, size * (is_big ? BIG_ENTRY_SIZE : SMALL_ENTRY_SIZE));