[commited] malloc: Fix checking for small negative values of tcache_key

Samuel Thibault samuel.thibault@ens-lyon.org
Sun Aug 10 21:46:08 GMT 2025


tcache_key is unsigned so we should turn it explicitly to signed before
taking its absolute value.
---
 malloc/malloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index c135916d32..e08873cad5 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3108,7 +3108,7 @@ tcache_key_initialize (void)
   int minimum_bits = __WORDSIZE / 4;
   int maximum_bits = __WORDSIZE - minimum_bits;
 
-  while (labs (tcache_key) <= 0x1000000
+  while (labs ((intptr_t) tcache_key) <= 0x1000000
       || stdc_count_ones (tcache_key) < minimum_bits
       || stdc_count_ones (tcache_key) > maximum_bits)
     {
-- 
2.47.2



More information about the Libc-alpha mailing list