[mudflap] fix infinite recursion in verbose trace

Submitted by Alexandre Oliva on Dec. 6, 2012, 4:02 a.m.

Details

Message ID or8v9bn7zg.fsf@livre.localdomain
State New
Headers show

Commit Message

Alexandre Oliva Dec. 6, 2012, 4:02 a.m.
mudflap's free overrider, when verbose traces enabled, calls output
functions that, at least on the version of glibc I'm using, calls free
recursively.  Since it happens to be free(NULL), it's quite easy to fix
this problem with the following simple patch.  Ok to install?

Comments

Richard Guenther Dec. 6, 2012, 9:19 a.m.
On Thu, Dec 6, 2012 at 5:02 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> mudflap's free overrider, when verbose traces enabled, calls output
> functions that, at least on the version of glibc I'm using, calls free
> recursively.  Since it happens to be free(NULL), it's quite easy to fix
> this problem with the following simple patch.  Ok to install?

Ok.

Thanks,
Richard.

>
>
>
> --
> Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/   FSF Latin America board member
> Free Software Evangelist      Red Hat Brazil Compiler Engineer
>

Patch hide | download patch | download mbox

Avoid infinite recursion on verbose mudflap

From: Alexandre Oliva <aoliva@redhat.com>

for  libmudflap/ChangeLog

	* mf-hooks1.c (free): Return on NULL before any logging.
---

 libmudflap/mf-hooks1.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/libmudflap/mf-hooks1.c b/libmudflap/mf-hooks1.c
index 3dd332e..7a27321 100644
--- a/libmudflap/mf-hooks1.c
+++ b/libmudflap/mf-hooks1.c
@@ -238,11 +238,11 @@  WRAPPER(void, free, void *buf)
   static int freeq_initialized = 0;
   DECLARE(void, free, void *);
 
-  BEGIN_PROTECT (free, buf);
-
   if (UNLIKELY(buf == NULL))
     return;
 
+  BEGIN_PROTECT (free, buf);
+
 #if PIC
   /* Check whether the given buffer might have come from a
      __mf_0fn_malloc/calloc call that for whatever reason was not