From b30602b78b56c1cc3195b87a094d5f67776da9a3 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 8 Dec 2005 03:25:22 +0000 Subject: [PATCH] Fixed bug #35594 (Multiple calls to getopt() may result in a crash). --- NEWS | 2 ++ ext/standard/basic_functions.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index abf086b34f..e68e15540d 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ PHP NEWS - Fixed many bugs in OCI8. (Tony) - Fixed crash and leak in mysqli when using 4.1.x client libraries and connecting to 5.x server. (Andrey) +- Fixed bug #35594 (Multiple calls to getopt() may result in a crash). + (rabbitt at gmail dot com, Ilia) - Fixed bug #35558 (mktime() interpreting 3 digit years incorrectly). (Ilia) - Fixed bug #35543 (php crash when calling non existing method of a class that extends PDO). (Tony) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f5d9661444..604ddf091d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1665,6 +1665,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) { -- 2.50.1