From 0dd448cbf19fade5aadb0c41f922e5901dd628ec Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 22 Mar 2011 22:41:16 +0000 Subject: [PATCH] - Fixed bug #54281 (Crash in non-initialized RecursiveIteratorIterator) --- NEWS | 2 ++ ext/spl/spl_iterators.c | 4 ++++ ext/spl/tests/bug54281.phpt | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 ext/spl/tests/bug54281.phpt 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-- +$v) { } + +?> +--EXPECTF-- +Fatal error: RecursiveIteratorIterator::rewind(): The RecursiveArrayIteratorIterator instance wasn't initialized properly in %s on line %d -- 2.40.0