From: Andreas Schwab Date: Sat, 22 Dec 2012 16:24:44 +0000 (+0100) Subject: mtrace: properly handle realloc (p, 0) X-Git-Tag: upstream/2.20~2720 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f5f40f465c5c1af651727e756fd007fd11f2236;p=platform%2Fupstream%2Flinaro-glibc.git mtrace: properly handle realloc (p, 0) --- diff --git a/ChangeLog b/ChangeLog index 8f46eba..2611e75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-01-03 Andreas Schwab + + [BZ #14981] + * malloc/mtrace.c (tr_reallochook): If realloc returns NULL when + size is zero, record memory as freed. + 2013-01-03 Andreas Jaeger * po/ia.po: Add new Interlingua translation. diff --git a/malloc/mtrace.c b/malloc/mtrace.c index af3b7f8..e9ccfa2 100644 --- a/malloc/mtrace.c +++ b/malloc/mtrace.c @@ -219,8 +219,13 @@ tr_reallochook (ptr, size, caller) tr_where (caller, info); if (hdr == NULL) - /* Failed realloc. */ - fprintf (mallstream, "! %p %#lx\n", ptr, (unsigned long int) size); + { + if (size != 0) + /* Failed realloc. */ + fprintf (mallstream, "! %p %#lx\n", ptr, (unsigned long int) size); + else + fprintf (mallstream, "- %p\n", ptr); + } else if (ptr == NULL) fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size); else