aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2025-09-09 23:03:26 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-09-09 23:05:00 +0200
commit245ea60b0e0f7d7abcc8ab3b693439df5f93fed9 (patch)
treec4ee735626faee5f742ace6374d0ca332938f694
parentb8253693b79fc9242f73aee7ffd75b5e9a4092f5 (diff)
downloadglibc-master.zip
glibc-master.tar.gz
glibc-master.tar.bz2
malloc: check "negative" tcache_key values by handHEADmaster
instead of undefined cases from casting uintptr_t into intptr_t.
-rw-r--r--malloc/malloc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 444dc61..18ef6b5 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)
{