]> granicus.if.org Git - php/commitdiff
MFB51: Fixed bug #35594 (Multiple calls to getopt() may result in a crash).
authorIlia Alshanetsky <iliaa@php.net>
Thu, 8 Dec 2005 03:25:42 +0000 (03:25 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 8 Dec 2005 03:25:42 +0000 (03:25 +0000)
ext/standard/basic_functions.c

index 914d339826751a6ca0ad1c7283b8b04c6a905e6e..7999b759e7744345e409f50750fe554ff19d297e 100644 (file)
@@ -1670,6 +1670,9 @@ PHP_FUNCTION(getopt)
        /* Disable getopt()'s error messages. */
        opterr = 0;
 
+       /* Force reinitialization of getopt() (via optind reset) on every call. */
+       optind = 0;
+
        /* Invoke getopt(3) on the argument array. */
 #ifdef HARTMUT_0
        while ((o = getopt_long(argc, argv, options, longopts, &longindex)) != -1) {