colder          Wed Mar 12 13:35:04 2008 UTC

  Modified files:              
    /php-src/ext/spl    spl_iterators.c 
    /php-src/ext/spl/tests      bug41828.phpt 
  Log:
  Fix bug #41828 (Fix crash on wrong instantiation)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.168&r2=1.169&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.168 
php-src/ext/spl/spl_iterators.c:1.169
--- php-src/ext/spl/spl_iterators.c:1.168       Thu Jan 10 10:11:21 2008
+++ php-src/ext/spl/spl_iterators.c     Wed Mar 12 13:35:04 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.168 2008/01/10 10:11:21 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.169 2008/03/12 13:35:04 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -702,8 +702,13 @@
        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_u_hash_find(&Z_OBJCE_P(zobj)->function_table, 
UG(unicode)?IS_UNICODE:IS_STRING, method, method_len+1, (void **) 
&function_handler) == FAILURE) {
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug41828.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/bug41828.phpt
diff -u /dev/null php-src/ext/spl/tests/bug41828.phpt:1.2
--- /dev/null   Wed Mar 12 13:35:04 2008
+++ php-src/ext/spl/tests/bug41828.phpt Wed Mar 12 13:35:04 2008
@@ -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



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to