From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85571 invoked by alias); 30 Oct 2019 12:21:41 -0000 Mailing-List: contact glibc-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: glibc-cvs-owner@sourceware.org List-Subscribe: Received: (qmail 85333 invoked by uid 10174); 30 Oct 2019 12:21:41 -0000 Date: Wed, 30 Oct 2019 12:21:00 -0000 Message-ID: <20191030122141.85330.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Arjun Shankar To: glibc-cvs@sourceware.org Subject: [glibc/release/2.28/master] Fix assertion in malloc.c:tcache_get. X-Act-Checkin: glibc X-Git-Author: Joseph Myers X-Git-Refname: refs/heads/release/2.28/master X-Git-Oldrev: b58bace7cede42c31c8047907b1e7ad318d24c32 X-Git-Newrev: 3640758943c856268bc12a3307838c2a65d2f9ea X-SW-Source: 2019-q4/txt/msg00193.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3640758943c856268bc12a3307838c2a65d2f9ea commit 3640758943c856268bc12a3307838c2a65d2f9ea Author: Joseph Myers 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 416c61a..668ae78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-02-04 Joseph Myers + + * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx] + with 0, not tcache->entries[tc_idx]. + 2019-09-13 Wilco Dijkstra * string/memmem.c (__memmem): Rewrite to improve performance. diff --git a/malloc/malloc.c b/malloc/malloc.c index 0e79700..78edbfc 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2941,7 +2941,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;