]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Fix checking for small negative values of tcache_key
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 10 Aug 2025 21:43:37 +0000 (23:43 +0200)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Mon, 11 Aug 2025 14:33:39 +0000 (14:33 +0000)
tcache_key is unsigned so we should turn it explicitly to signed before
taking its absolute value.

(cherry picked from commit 8543577b04ded6d979ffcc5a818930e4d74d0645)

malloc/malloc.c

index e4e2f03600b5019209dc6b30bad7a4c106778db6..5f3e701fd1358dfde634f19f5fbda1ba194a1f75 100644 (file)
@@ -3165,7 +3165,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)
     {