mtrace: properly handle realloc (p, 0)

This commit is contained in:
Andreas Schwab 2012-12-22 17:24:44 +01:00
parent 4056f4a03a
commit 2f5f40f465
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2013-01-03 Andreas Schwab <schwab@linux-m68k.org>
[BZ #14981]
* malloc/mtrace.c (tr_reallochook): If realloc returns NULL when
size is zero, record memory as freed.
2013-01-03 Andreas Jaeger <aj@suse.de> 2013-01-03 Andreas Jaeger <aj@suse.de>
* po/ia.po: Add new Interlingua translation. * po/ia.po: Add new Interlingua translation.

View File

@ -219,8 +219,13 @@ tr_reallochook (ptr, size, caller)
tr_where (caller, info); tr_where (caller, info);
if (hdr == NULL) if (hdr == NULL)
{
if (size != 0)
/* Failed realloc. */ /* Failed realloc. */
fprintf (mallstream, "! %p %#lx\n", ptr, (unsigned long int) size); fprintf (mallstream, "! %p %#lx\n", ptr, (unsigned long int) size);
else
fprintf (mallstream, "- %p\n", ptr);
}
else if (ptr == NULL) else if (ptr == NULL)
fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size); fprintf (mallstream, "+ %p %#lx\n", hdr, (unsigned long int) size);
else else