1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Mon, 25 Aug 2025 22:23:02 +0200
Subject: ghash: Fix signed integer overflow in g_hash_table_set_shift
Shifting 1 by 31 bits triggers a signed integer overflow. Use 1u
for unsigned data type to allow such operation.
Bug: https://gitlab.gnome.org/GNOME/glib/-/issues/672
Origin: upstream, 2.86.1, commit:f8bda4d10990a1e229fc3c3fd09b263ef6f99288
---
glib/ghash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/glib/ghash.c b/glib/ghash.c
index 352098c..d5c84ac 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -298,7 +298,7 @@ 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->size = 1u << shift;
hash_table->mod = prime_mod [shift];
/* hash_table->size is always a power of two, so we can calculate the mask
|