Skip to content

Commit 6457c34

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fix bug #68095 - invalid read in php_getopt()
2 parents 0f5858e + c5659cb commit 6457c34

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main/getopt.c

+8
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,17 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
5959
{
6060
static int optchr = 0;
6161
static int dash = 0; /* have already seen the - */
62+
static char **prev_optarg = NULL;
6263

6364
php_optidx = -1;
6465

66+
if(prev_optarg && prev_optarg != optarg) {
67+
/* reset the state */
68+
optchr = 0;
69+
dash = 0;
70+
}
71+
prev_optarg = optarg;
72+
6573
if (*optind >= argc) {
6674
return(EOF);
6775
}

0 commit comments

Comments
 (0)