]> granicus.if.org Git - php/commitdiff
Fix #49972 (AppendIterator undefined function crash)
authorJohannes Schlüter <johannes@php.net>
Fri, 23 Oct 2009 16:47:35 +0000 (16:47 +0000)
committerJohannes Schlüter <johannes@php.net>
Fri, 23 Oct 2009 16:47:35 +0000 (16:47 +0000)
ext/spl/spl_iterators.c
ext/spl/tests/bug49972.phpt [new file with mode: 0755]

index 0d9476e66c89c70384c7583485be83109a29a64d..a32bfd8b24117bc406e0aeea3e1aa1d1a8875b50 100755 (executable)
@@ -1215,7 +1215,7 @@ static union _zend_function *spl_dual_it_get_method(zval **object_ptr, zstr meth
        intern = (spl_dual_it_object*)zend_object_store_get_object(*object_ptr TSRMLS_CC);
 
        function_handler = std_object_handlers.get_method(object_ptr, method, method_len TSRMLS_CC);
-       if (!function_handler) {
+       if (!function_handler && intern->inner.ce) {
                if (zend_u_hash_find(&intern->inner.ce->function_table, IS_UNICODE, method, method_len+1, (void **) &function_handler) == FAILURE) {
                        if (Z_OBJ_HT_P(intern->inner.zobject)->get_method) {
                                *object_ptr = intern->inner.zobject;
diff --git a/ext/spl/tests/bug49972.phpt b/ext/spl/tests/bug49972.phpt
new file mode 100755 (executable)
index 0000000..843c251
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #49972 (AppendIterator undefined function crash)
+--FILE--
+<?php
+
+$iterator = new AppendIterator();
+$iterator->undefined();
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined method AppendIterator::undefined() in %s on line %d