This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc/release/2.29/master] Fix assertion in malloc.c:tcache_get.
- From: Arjun Shankar <arjun at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 18 Nov 2019 17:58:09 -0000
- Subject: [glibc/release/2.29/master] Fix assertion in malloc.c:tcache_get.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9a3ff995bdbb841fc3e9746ba77312b6e362a87c
commit 9a3ff995bdbb841fc3e9746ba77312b6e362a87c
Author: Joseph Myers <joseph@codesourcery.com>
Date: Mon Feb 4 23:46:58 2019 +0000
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)
Diff:
---
ChangeLog | 5 +++++
malloc/malloc.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 8c8b884..0c7b7e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 0abd653..59fa1a1 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;