diff options
author | Dave Korn <dave.korn.cygwin@gmail.com> | 2010-06-09 16:46:59 +0000 |
---|---|---|
committer | Dave Korn <davek@gcc.gnu.org> | 2010-06-09 16:46:59 +0000 |
commit | 807303cf1432a90d6b15fe8f73fc6094fe829ad5 (patch) | |
tree | 5e89c85c14285328b9131a92b1e30284dda64105 | |
parent | 289e52fd12ea388be5e7d3de3dc797fd87004fee (diff) | |
download | gcc-807303cf1432a90d6b15fe8f73fc6094fe829ad5.zip gcc-807303cf1432a90d6b15fe8f73fc6094fe829ad5.tar.gz gcc-807303cf1432a90d6b15fe8f73fc6094fe829ad5.tar.bz2 |
opts-common.c (prune_options): Ensure replacement argv array is correctly terminated by a NULL entry.
* opts-common.c (prune_options): Ensure replacement argv array
is correctly terminated by a NULL entry.
From-SVN: r160496
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/opts-common.c | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bc5886e..b60675d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-06-09 Dave Korn <dave.korn.cygwin@gmail.com> + + * opts-common.c (prune_options): Ensure replacement argv array + is correctly terminated by a NULL entry. + 2010-06-09 Jan Hubicka <jh@suse.cz> * cgraph.h (varpool_first_static_initializer, diff --git a/gcc/opts-common.c b/gcc/opts-common.c index b70b823..d9368d5 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -132,6 +132,10 @@ prune_options (int *argcp, char ***argvp) { int argc = *argcp; int *options = XNEWVEC (int, argc); + /* We will only return this replacement argv if we remove at least + one argument, so it does not need to be size (argc + 1) to + make room for the terminating NULL because we will always have + freed up at least one slot when we end up using it at all. */ char **argv = XNEWVEC (char *, argc); int i, arg_count, need_prune = 0; const struct cl_option *option; @@ -225,6 +229,9 @@ keep: { *argcp = arg_count; *argvp = argv; + /* Add NULL-termination. Guaranteed not to overflow because + arg_count here can only be less than argc. */ + argv[arg_count] = 0; } else { |