From: Jani Taskinen Date: Thu, 26 Jul 2007 15:24:06 +0000 (+0000) Subject: MFH: - Fixed bug #42107 (sscanf broken when using %2$s type format parameters) X-Git-Tag: php-5.2.4RC1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68b823564d06ceda58f096f3fd02a11b040d8d42;p=php MFH: - Fixed bug #42107 (sscanf broken when using %2$s type format parameters) --- diff --git a/NEWS b/NEWS index 5672033d9d..85129b5aa7 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,7 @@ PHP NEWS - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory already exists). (Pierre) +- Fixed Bug #42107 (sscanf broken when using %2$s format parameters). (Jani) - Fixed bug #42090 (json_decode causes segmentation fault). (Hannes) - Fixed bug #42072 (No warning message for clearstatcache() with arguments). (Ilia) diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index b299a3ed1d..b711522e4c 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -649,6 +649,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, return FAILURE; } } + varStart = 0; /* Array index starts from 0 */ } baseString = string; diff --git a/ext/standard/tests/strings/bug42107.phpt b/ext/standard/tests/strings/bug42107.phpt new file mode 100644 index 0000000000..d97f8917e2 --- /dev/null +++ b/ext/standard/tests/strings/bug42107.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #42107 (sscanf() broken when using %2$s type format parameters) +--FILE-- + +--EXPECTF-- +array(2) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" +} +array(2) { + [0]=> + string(3) "two" + [1]=> + string(3) "one" +} +-- +string(3) "one" +string(3) "two" +string(3) "two" +string(3) "one" +-- +array(2) { + [0]=> + NULL + [1]=> + NULL +} +array(1) { + [0]=> + NULL +} +Done