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]

[PATCH] Fix memory leak in the C/C++ front-ends


This memory leak only really shows up when you don't supply -quiet
to cc1/cc1plus.  We were not freeing the memory we allocated.

OK? Bootstrapped and tested on powerpc-darwin.

Thanks,
Andrew Pinski

ChangeLog:

	* c-common.c (fname_as_string): Free namep before returning
	after interpreting the string.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.576
diff -u -p -r1.576 c-common.c
--- c-common.c	3 Oct 2004 20:52:59 -0000	1.576
+++ c-common.c	12 Oct 2004 14:39:45 -0000
@@ -755,7 +755,10 @@ fname_as_string (int pretty_p)
       strname.len = len - 1;

       if (cpp_interpret_string (parse_in, &strname, 1, &cstr, false))
-	return (char *) cstr.text;
+        {
+	  free (namep);
+	  return (char *) cstr.text;
+	}
     }
   else
     namep = xstrdup (name);


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