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