5f7b84
commit 3640758943c856268bc12a3307838c2a65d2f9ea
5f7b84
Author: Joseph Myers <joseph@codesourcery.com>
5f7b84
Date:   Mon Feb 4 23:46:58 2019 +0000
5f7b84
5f7b84
    Fix assertion in malloc.c:tcache_get.
5f7b84
    
5f7b84
    One of the warnings that appears with -Wextra is "ordered comparison
5f7b84
    of pointer with integer zero" in malloc.c:tcache_get, for the
5f7b84
    assertion:
5f7b84
    
5f7b84
      assert (tcache->entries[tc_idx] > 0);
5f7b84
    
5f7b84
    Indeed, a "> 0" comparison does not make sense for
5f7b84
    tcache->entries[tc_idx], which is a pointer.  My guess is that
5f7b84
    tcache->counts[tc_idx] is what's intended here, and this patch changes
5f7b84
    the assertion accordingly.
5f7b84
    
5f7b84
    Tested for x86_64.
5f7b84
    
5f7b84
            * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx]
5f7b84
            with 0, not tcache->entries[tc_idx].
5f7b84
    
5f7b84
    (cherry picked from commit 77dc0d8643aa99c92bf671352b0a8adde705896f)
5f7b84
5f7b84
diff --git a/malloc/malloc.c b/malloc/malloc.c
5f7b84
index 92239b3324584060..998879aededf0d7c 100644
5f7b84
--- a/malloc/malloc.c
5f7b84
+++ b/malloc/malloc.c
5f7b84
@@ -2948,7 +2948,7 @@ tcache_get (size_t tc_idx)
5f7b84
 {
5f7b84
   tcache_entry *e = tcache->entries[tc_idx];
5f7b84
   assert (tc_idx < TCACHE_MAX_BINS);
5f7b84
-  assert (tcache->entries[tc_idx] > 0);
5f7b84
+  assert (tcache->counts[tc_idx] > 0);
5f7b84
   tcache->entries[tc_idx] = e->next;
5f7b84
   --(tcache->counts[tc_idx]);
5f7b84
   e->key = NULL;