summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDaniel van Gerpen <daniel@vangerpen.de>2018-01-10 22:40:53 +0000
committerJeff Law <law@gcc.gnu.org>2018-01-10 15:40:53 -0700
commit3ec62f54062b50d0c9e0ed55f4d83147df56fc92 (patch)
tree5c270f9ec9587a926b4a50aac29ee88f77acc61e /libiberty
parent83cbbe3aa8125d97f832c4644b4e381ac7afd5ae (diff)
argv.c (expandargv): Correct check for dynamically allocated argv.
2018-01-10 Daniel van Gerpen <daniel@vangerpen.de> * argv.c (expandargv): Correct check for dynamically allocated argv. From-SVN: r256460
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/argv.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index f1f6d8dee5b..817ebc644ea 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-10 Daniel van Gerpen <daniel@vangerpen.de>
+
+ * argv.c (expandargv): Correct check for dynamically
+ allocated argv.
+
2018-01-03 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
diff --git a/libiberty/argv.c b/libiberty/argv.c
index c6a79d215e3..4f66c8979b2 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -367,8 +367,8 @@ expandargv (int *argcp, char ***argvp)
{
/* The argument we are currently processing. */
int i = 0;
- /* Non-zero if ***argvp has been dynamically allocated. */
- int argv_dynamic = 0;
+ /* To check if ***argvp has been dynamically allocated. */
+ char ** const original_argv = *argvp;
/* Limit the number of response files that we parse in order
to prevent infinite recursion. */
unsigned int iteration_limit = 2000;
@@ -449,7 +449,7 @@ expandargv (int *argcp, char ***argvp)
/* Parse the string. */
file_argv = buildargv (buffer);
/* If *ARGVP is not already dynamically allocated, copy it. */
- if (!argv_dynamic)
+ if (*argvp == original_argv)
*argvp = dupargv (*argvp);
/* Count the number of arguments. */
file_argc = 0;