mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-30 10:56:37 +02:00
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.
This commit is contained in:
@@ -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];
|
||||
|
||||
|
Reference in New Issue
Block a user