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