[binutils-gdb] * argv.c (expandargv): Fix memory leak for expanded arguments.

Richard Earnshaw rearnsha@sourceware.org
Thu May 31 09:18:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e4554bf70235e3ebb10521ddbcbb2bf17abe4865

commit e4554bf70235e3ebb10521ddbcbb2bf17abe4865
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Apr 30 18:00:49 2018 +0000

    * argv.c (expandargv): Fix memory leak for expanded arguments.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259775 138bc75d-0d04-0410-961f-82ee72b054a4

Diff:
---
 libiberty/ChangeLog | 4 ++++
 libiberty/argv.c    | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 742b2fa..a116d37 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2018-04-30  Daniel van Gerpen  <daniel@vangerpen.de>
+
+	* argv.c (expandargv): Fix memory leak for copied argv.
+
 2018-04-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	PR lto/81968
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 4f66c89..8ead947 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -455,6 +455,8 @@ expandargv (int *argcp, char ***argvp)
       file_argc = 0;
       while (file_argv[file_argc])
 	++file_argc;
+      /* Free the original option's memory.  */
+      free ((*argvp)[i]);
       /* Now, insert FILE_ARGV into ARGV.  The "+1" below handles the
 	 NULL terminator at the end of ARGV.  */ 
       *argvp = ((char **)



More information about the Binutils-cvs mailing list