diff options
author | 2019-02-04 23:46:58 +0000 | |
---|---|---|
committer | 2019-11-25 02:07:14 +0100 | |
commit | 5619fc1ee1f5a1a4c3d2b716903c6c32f1123345 (patch) | |
tree | 6a0e81856545b98faef175e0392d5a6d2fdf087d | |
parent | Fix alignment of TLS variables for tls variant TLS_TCB_AT_TP [BZ #23403] (diff) | |
download | glibc-5619fc1ee1f5a1a4c3d2b716903c6c32f1123345.tar.gz glibc-5619fc1ee1f5a1a4c3d2b716903c6c32f1123345.tar.bz2 glibc-5619fc1ee1f5a1a4c3d2b716903c6c32f1123345.zip |
Fix assertion in malloc.c:tcache_get.
One of the warnings that appears with -Wextra is "ordered comparison
of pointer with integer zero" in malloc.c:tcache_get, for the
assertion:
assert (tcache->entries[tc_idx] > 0);
Indeed, a "> 0" comparison does not make sense for
tcache->entries[tc_idx], which is a pointer. My guess is that
tcache->counts[tc_idx] is what's intended here, and this patch changes
the assertion accordingly.
Tested for x86_64.
* malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx]
with 0, not tcache->entries[tc_idx].
(cherry picked from commit 77dc0d8643aa99c92bf671352b0a8adde705896f)
(cherry picked from commit 9a3ff995bdbb841fc3e9746ba77312b6e362a87c)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | malloc/malloc.c | 2 |
2 files changed, 6 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2019-02-04 Joseph Myers <joseph@codesourcery.com> + + * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx] + with 0, not tcache->entries[tc_idx]. + 2019-02-06 Stefan Liebler <stli@linux.ibm.com> [BZ #23403] diff --git a/malloc/malloc.c b/malloc/malloc.c index 0abd653be2..59fa1a18a5 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2948,7 +2948,7 @@ tcache_get (size_t tc_idx) { tcache_entry *e = tcache->entries[tc_idx]; assert (tc_idx < TCACHE_MAX_BINS); - assert (tcache->entries[tc_idx] > 0); + assert (tcache->counts[tc_idx] > 0); tcache->entries[tc_idx] = e->next; --(tcache->counts[tc_idx]); e->key = NULL; |