summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rwxr-xr-xext/spl/spl_iterators.c4
-rw-r--r--ext/spl/tests/bug54281.phpt15
3 files changed, 21 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 6204879270..e3e7f7d543 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,8 @@ PHP NEWS
- SPL extension:
. Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting
with \0). (Gustavo)
+ . Fixed bug #54281 (Crash in non-initialized RecursiveIteratorIterator).
+ (Felipe)
17 Mar 2011, PHP 5.3.6
- Upgraded bundled Sqlite3 to version 3.7.4. (Ilia)
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 7fa34272d9..9383d71992 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -360,6 +360,10 @@ next_step:
static void spl_recursive_it_rewind_ex(spl_recursive_it_object *object, zval *zthis TSRMLS_DC)
{
zend_object_iterator *sub_iter;
+
+ if (!object->iterators) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", Z_OBJCE_P(zthis)->name);
+ }
while (object->level) {
sub_iter = object->iterators[object->level].iterator;
diff --git a/ext/spl/tests/bug54281.phpt b/ext/spl/tests/bug54281.phpt
new file mode 100644
index 0000000000..d42d9e585d
--- /dev/null
+++ b/ext/spl/tests/bug54281.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #54281 (Crash in spl_recursive_it_rewind_ex)
+--FILE--
+<?php
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator {
+ function __construct($it, $max_depth) { }
+}
+$it = new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array()), 2);
+
+foreach($it as $k=>$v) { }
+
+?>
+--EXPECTF--
+Fatal error: RecursiveIteratorIterator::rewind(): The RecursiveArrayIteratorIterator instance wasn't initialized properly in %s on line %d