summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Kneuss <colder@php.net>2008-03-12 13:24:24 +0000
committerEtienne Kneuss <colder@php.net>2008-03-12 13:24:24 +0000
commitf2c14fd8b0085673dda152b43973e0435d14c2a4 (patch)
tree6a91e64589404d4f4b6abba1f3324f1385325341
parenta000cbd9551953a70cd9dd5507bd393c97e69392 (diff)
downloadphp-git-f2c14fd8b0085673dda152b43973e0435d14c2a4.tar.gz
Fix bug #41828 (Fix crash on wrong instantiation)
-rwxr-xr-xext/spl/spl_iterators.c9
-rw-r--r--ext/spl/tests/bug41828.phpt21
2 files changed, 28 insertions, 2 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index c356c5bdfc..d84fc2e58c 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -693,8 +693,13 @@ static union _zend_function *spl_recursive_it_get_method(zval **object_ptr, char
union _zend_function *function_handler;
spl_recursive_it_object *object = (spl_recursive_it_object*)zend_object_store_get_object(*object_ptr TSRMLS_CC);
long level = object->level;
- zval *zobj = object->iterators[level].zobject;
-
+ zval *zobj;
+
+ if (!object->iterators) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", Z_OBJCE_PP(object_ptr)->name);
+ }
+ zobj = object->iterators[level].zobject;
+
function_handler = std_object_handlers.get_method(object_ptr, method, method_len TSRMLS_CC);
if (!function_handler) {
if (zend_hash_find(&Z_OBJCE_P(zobj)->function_table, method, method_len+1, (void **) &function_handler) == FAILURE) {
diff --git a/ext/spl/tests/bug41828.phpt b/ext/spl/tests/bug41828.phpt
new file mode 100644
index 0000000000..6053e0e446
--- /dev/null
+++ b/ext/spl/tests/bug41828.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #41828 (Segfault if extended constructor of RecursiveIterator doesn't call its parent)
+--FILE--
+<?php
+class foo extends RecursiveIteratorIterator {
+
+ public function __construct($str) {
+ }
+
+ public function bar() {
+ }
+}
+
+$foo = new foo("This is bar");
+echo $foo->bar();
+
+?>
+==DONE==
+<?php exit(0); ?>
+--EXPECTF--
+Fatal error: main(): The foo instance wasn't initialized properly in %s on line %d