This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/14526: c++filt is crashed on large files
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Aug 2012 11:33:47 -0700
- Subject: PATCH: PR binutils/14526: c++filt is crashed on large files
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
buildargv uses alloca to allocate buffer, whose size may exceed stack
limit. This patch replaces alloca with xmalloc/free. OK to install?
Thanks.
H.J.
---
PR binutils/14526
* argv.c (buildargv): Replace alloca with xmalloc/free.
diff --git a/libiberty/argv.c b/libiberty/argv.c
index ca53f91..4cef3bc 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -191,7 +191,7 @@ char **buildargv (const char *input)
if (input != NULL)
{
- copybuf = (char *) alloca (strlen (input) + 1);
+ copybuf = (char *) xmalloc (strlen (input) + 1);
/* Is a do{}while to always execute the loop once. Always return an
argv, even for null strings. See NOTES above, test case below. */
do
@@ -297,6 +297,8 @@ char **buildargv (const char *input)
consume_whitespace (&input);
}
while (*input != EOS);
+
+ free (copybuf);
}
return (argv);
}