helly           Tue Apr 27 13:12:11 2004 EDT

  Modified files:              
    /php-src/ext/spl    spl_iterators.c 
  Log:
  - Some pretection against out-of-memory situations
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.33&r2=1.34&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.33 php-src/ext/spl/spl_iterators.c:1.34
--- php-src/ext/spl/spl_iterators.c:1.33        Tue Apr 27 11:41:26 2004
+++ php-src/ext/spl/spl_iterators.c     Tue Apr 27 13:12:11 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.33 2004/04/27 15:41:26 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.34 2004/04/27 17:12:11 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -230,9 +230,11 @@
                                ce = object->iterators[object->level].ce;
                                zobject = object->iterators[object->level].zobject;
                                zend_call_method_with_0_params(&zobject, ce, NULL, 
"getchildren", &child);
-                               ce = Z_OBJCE_P(child);
+                               ce = child ? Z_OBJCE_P(child) : NULL;
                                if (!ce || !instanceof_function(ce, 
spl_ce_RecursiveIterator TSRMLS_CC)) {
-                                       zval_ptr_dtor(&child);
+                                       if (child) {
+                                               zval_ptr_dtor(&child);
+                                       }
                                        
zend_throw_exception(zend_exception_get_default(), "Objects returned by 
RecursiveIterator::getChildren() must implement RecursiveIterator", 0 TSRMLS_CC);
                                        return;
                                }
@@ -610,7 +612,7 @@
 
 static INLINE void spl_dual_it_free(spl_dual_it_object *intern TSRMLS_DC)
 {
-       if (intern->inner.iterator->funcs->invalidate_current) {
+       if (intern->inner.iterator && 
intern->inner.iterator->funcs->invalidate_current) {
                
intern->inner.iterator->funcs->invalidate_current(intern->inner.iterator TSRMLS_CC);
        }
        if (intern->current.data) {
@@ -740,11 +742,13 @@
 
        while (spl_dual_it_fetch(intern, 1 TSRMLS_CC) == SUCCESS) {
                zend_call_method_with_0_params(&zthis, intern->std.ce, NULL, "accept", 
&retval);
-               if (zend_is_true(retval)) {
+               if (retval) {
+                       if (zend_is_true(retval)) {
+                               zval_ptr_dtor(&retval);
+                               return;
+                       }
                        zval_ptr_dtor(&retval);
-                       return;
                }
-               zval_ptr_dtor(&retval);
 
                intern->inner.iterator->funcs->move_forward(intern->inner.iterator 
TSRMLS_CC);
        }

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

Reply via email to