From d7274d718e6f3655eabe311d4eb70fabb5ffa7ef Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 10 Aug 2025 23:43:37 +0200 Subject: [PATCH] malloc: Fix checking for small negative values of tcache_key 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index e4e2f03600..5f3e701fd1 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -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) { -- 2.47.2