This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] libiberty/argv.c, expandargv, close memory leak
- From: Michael Snyder <msnyder at vmware dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "dj at redhat dot com" <dj at redhat dot com>
- Date: Sun, 06 Mar 2011 14:44:44 -0800
- Subject: [RFA] libiberty/argv.c, expandargv, close memory leak
OK?
2011-03-06 Michael Snyder <msnyder@vmware.com>
* argv.c (expandargv): Close memory leak.
Index: argv.c
===================================================================
RCS file: /cvs/src/src/libiberty/argv.c,v
retrieving revision 1.22
diff -u -p -r1.22 argv.c
--- argv.c 13 Aug 2010 11:36:10 -0000 1.22
+++ argv.c 6 Mar 2011 22:41:02 -0000
@@ -439,7 +439,10 @@ expandargv (int *argcp, char ***argvp)
due to CR/LF->CR translation when reading text files.
That does not in-and-of itself indicate failure. */
&& ferror (f))
- goto error;
+ {
+ xfree (buffer);
+ goto error;
+ }
/* Add a NUL terminator. */
buffer[len] = '\0';
/* If the file is empty or contains only whitespace, buildargv would