svn: /php/php-src/ branches/PHP_5_3/ext/spl/tests/bug54304.phpt branches/PHP_5_4/ext/spl/tests/bug54304.phpt trunk/ext/spl/tests/bug54304.phpt
| From: | Hannes Magnusson | Date: | Mon, 12 Sep 2011 17:20:44 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/spl/tests/bug54304.phpt branches/PHP_5_4/ext/spl/tests/bug54304.phpt trunk/ext/spl/tests/bug54304.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-66470@lists.php.net to get a copy of this message | ||
bjori Mon, 12 Sep 2011 17:20:44 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=316561
Log:
Test for non-string replacement, bug#54304
Bug: https://bugs.php.net/54304 (Closed) Invalid read in
RegexIterator::accept() causes crash
Changed paths:
A php/php-src/branches/PHP_5_3/ext/spl/tests/bug54304.phpt
A php/php-src/branches/PHP_5_4/ext/spl/tests/bug54304.phpt
A php/php-src/trunk/ext/spl/tests/bug54304.phpt
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug54304.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug54304.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug54304.phpt 2011-09-12 17:20:44 UTC (rev 316561)
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54304 (Setting replacement value for RegexIterator doesn't work)
+--FILE--
+<?php
+class foo extends ArrayIterator {
+ public function __construct( ) {
+ parent::__construct(array(
+ 'test3'=>'test999'));
+ }
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = 42;
+var_dump($i->replacement);
+foreach ($i as $name=>$value) {
+ var_dump($name, $value);
+}
+var_dump($i->replacement);
+?>
+--EXPECT--
+int(42)
+string(5) "test3"
+string(2) "42"
+int(42)
+
Added: php/php-src/branches/PHP_5_4/ext/spl/tests/bug54304.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/tests/bug54304.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/spl/tests/bug54304.phpt 2011-09-12 17:20:44 UTC (rev 316561)
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54304 (Setting replacement value for RegexIterator doesn't work)
+--FILE--
+<?php
+class foo extends ArrayIterator {
+ public function __construct( ) {
+ parent::__construct(array(
+ 'test3'=>'test999'));
+ }
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = 42;
+var_dump($i->replacement);
+foreach ($i as $name=>$value) {
+ var_dump($name, $value);
+}
+var_dump($i->replacement);
+?>
+--EXPECT--
+int(42)
+string(5) "test3"
+string(2) "42"
+int(42)
+
Added: php/php-src/trunk/ext/spl/tests/bug54304.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug54304.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug54304.phpt 2011-09-12 17:20:44 UTC (rev 316561)
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54304 (Setting replacement value for RegexIterator doesn't work)
+--FILE--
+<?php
+class foo extends ArrayIterator {
+ public function __construct( ) {
+ parent::__construct(array(
+ 'test3'=>'test999'));
+ }
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = 42;
+var_dump($i->replacement);
+foreach ($i as $name=>$value) {
+ var_dump($name, $value);
+}
+var_dump($i->replacement);
+?>
+--EXPECT--
+int(42)
+string(5) "test3"
+string(2) "42"
+int(42)
+