From b32aed174aa618bf1eb198f55ed2dacc0d24a9c8 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Wed, 20 Aug 2025 20:15:41 +0200 Subject: [PATCH] ghash: Call g_error if hash table grows too large Gracefully handle the case when too many items (billions) are added to a hash table. --- glib/ghash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/glib/ghash.c b/glib/ghash.c index 82b750689..e922e1a88 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -289,6 +289,9 @@ static const gint prime_mod [] = static void g_hash_table_set_shift (GHashTable *hash_table, gint shift) { + if (shift > 31) + g_error ("adding more entries to hash table would overflow"); + hash_table->size = 1 << shift; hash_table->mod = prime_mod [shift];