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