From 245ea60b0e0f7d7abcc8ab3b693439df5f93fed9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 9 Sep 2025 23:03:26 +0200 Subject: [PATCH] malloc: check "negative" tcache_key values by hand instead of undefined cases from casting uintptr_t into intptr_t. --- malloc/malloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 444dc61825..18ef6b5cb8 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3150,7 +3150,8 @@ tcache_key_initialize (void) int minimum_bits = __WORDSIZE / 4; int maximum_bits = __WORDSIZE - minimum_bits; - while (labs ((intptr_t) tcache_key) <= 0x1000000 + while (tcache_key <= 0x1000000 + || tcache_key >= ((uintptr_t) ULONG_MAX) - 0x1000000 || stdc_count_ones (tcache_key) < minimum_bits || stdc_count_ones (tcache_key) > maximum_bits) { -- 2.47.3