This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ping [Patch libiberty]: Fix memory leak in ada demangler



On Sep 21, 2009, at 11:27 PM, DJ Delorie wrote:



Looks like demangled can't be NULL at that point.

Why ?

Because it's unconditionally dereferenced just before that point:

Yes, I read your reply too quickly. Sorry for the noise.


So the lightest version of the patch is:

Tristan.

libiberty/
2009-09-22  Matthew Gingell <gingell@adacore.com>

* cplus-dem.c (ada_demangle): Ensure demangled is freed.

Index: cplus-dem.c
===================================================================
--- cplus-dem.c	(revision 151967)
+++ cplus-dem.c	(working copy)
@@ -984,7 +984,10 @@
       goto Suppress;

   if (! changed)
-    return NULL;
+    {
+      free (demangled);
+      return NULL;
+    }
   else
     return demangled;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]