]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix boundary error
authorDJ Delorie <dj@delorie.com>
Tue, 31 Jan 2017 21:23:57 +0000 (16:23 -0500)
committerDJ Delorie <dj@delorie.com>
Wed, 1 Feb 2017 01:00:02 +0000 (20:00 -0500)
malloc/malloc.c

index d19fa03a1a2e0375c4fd77d8388f9eb62f40f736..197fe0c7bec7ae99fa77e30d7f05e520cc110ecb 100644 (file)
@@ -1791,7 +1791,7 @@ static struct malloc_par mp_ =
   ,
   .tcache_count = TCACHE_FILL_COUNT,
   .tcache_max = TCACHE_IDX,
-  .tcache_max_bytes = tidx2usize (TCACHE_IDX),
+  .tcache_max_bytes = tidx2usize (TCACHE_IDX-1),
   .tcache_unsorted_limit = 0 /* No limit */
 #endif
 };
@@ -3632,9 +3632,9 @@ _int_malloc (mstate av, size_t bytes)
 
 #if USE_TCACHE
   INTERNAL_SIZE_T tcache_nb = 0;
-  if (csize2tidx (nb) <= mp_.tcache_max)
-    tcache_nb = nb;
   size_t tc_idx = csize2tidx (nb);
+  if (tc_idx < mp_.tcache_max)
+    tcache_nb = nb;
   int return_cached = 0;
 
   tcache_unsorted_count = 0;