This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] expandargv: fix memory leak
- From: Daniel van Gerpen <daniel at vangerpen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 30 Dec 2017 16:47:09 +0100
- Subject: [PATCH] expandargv: fix memory leak
- Authentication-results: sourceware.org; auth=none
When the responsefile's contents are interpolated into the argument vector,
the pointer to original option string ("@filename") became lost. This
caused a small leak for every responsefile on the commandline.
---
libiberty/argv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libiberty/argv.c b/libiberty/argv.c
index c544dad73ee..bdd4ace4cb6 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 **)
--
2.11.0