summaryrefslogtreecommitdiff
path: root/main/getopt.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-10-27 19:10:43 -0700
committerStanislav Malyshev <stas@php.net>2014-10-27 19:10:43 -0700
commit6457c34ad8adec41457ff09d2d8c00792f66c964 (patch)
tree1e1fe109b63fcedddf6e86c472e5975981372e43 /main/getopt.c
parent0f5858e3a3283514f97b9fee539a38b68e0698da (diff)
parentc5659cb8bd53ac2fd9952ca7c5445bda8dcaea24 (diff)
downloadphp-git-6457c34ad8adec41457ff09d2d8c00792f66c964.tar.gz
Merge branch 'PHP-5.6'
* PHP-5.6: Fix bug #68095 - invalid read in php_getopt()
Diffstat (limited to 'main/getopt.c')
-rw-r--r--main/getopt.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/main/getopt.c b/main/getopt.c
index 49ae2ba04a..9338648b10 100644
--- a/main/getopt.c
+++ b/main/getopt.c
@@ -59,9 +59,17 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
{
static int optchr = 0;
static int dash = 0; /* have already seen the - */
+ static char **prev_optarg = NULL;
php_optidx = -1;
+ if(prev_optarg && prev_optarg != optarg) {
+ /* reset the state */
+ optchr = 0;
+ dash = 0;
+ }
+ prev_optarg = optarg;
+
if (*optind >= argc) {
return(EOF);
}