helly           Sun Mar  6 20:15:04 2005 EDT

  Modified files:              (Branch: PHP_5_0)
    /php-src/ext/spl    spl_iterators.c 
  Log:
  - MFH avoid exception problems
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.38.2.8&r2=1.38.2.9&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.38.2.8 
php-src/ext/spl/spl_iterators.c:1.38.2.9
--- php-src/ext/spl/spl_iterators.c:1.38.2.8    Mon Jan 24 15:25:58 2005
+++ php-src/ext/spl/spl_iterators.c     Sun Mar  6 20:15:03 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.38.2.8 2005/01/24 20:25:58 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.38.2.9 2005/03/07 01:15:03 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -187,8 +187,9 @@
        zend_class_entry          *ce;
        zval                      *retval, *child;
        zend_object_iterator      *sub_iter;
+       int                       has_children;
 
-       while (1) {
+       while (!EG(exception)) {
 next_step:
                iterator = object->iterators[object->level].iterator;
                switch (object->iterators[object->level].state) {
@@ -204,19 +205,21 @@
                                ce = object->iterators[object->level].ce;
                                zobject = 
object->iterators[object->level].zobject;
                                zend_call_method_with_0_params(&zobject, ce, 
NULL, "haschildren", &retval);
-                               if (zend_is_true(retval)) {
+                               if (retval) {
+                                       has_children = zend_is_true(retval);
                                        zval_ptr_dtor(&retval);
-                                       switch (object->mode) {
-                                               case RIT_LEAVES_ONLY:
-                                               case RIT_CHILD_FIRST:
-                                                       
object->iterators[object->level].state = RS_CHILD;
-                                                       goto next_step;
-                                               case RIT_SELF_FIRST:
-                                                       
object->iterators[object->level].state = RS_SELF;
-                                                       goto next_step;
+                                       if (has_children) {
+                                               switch (object->mode) {
+                                                       case RIT_LEAVES_ONLY:
+                                                       case RIT_CHILD_FIRST:
+                                                               
object->iterators[object->level].state = RS_CHILD;
+                                                               goto next_step;
+                                                       case RIT_SELF_FIRST:
+                                                               
object->iterators[object->level].state = RS_SELF;
+                                                               goto next_step;
+                                               }
                                        }
                                }
-                               zval_ptr_dtor(&retval);
                                object->iterators[object->level].state = 
RS_NEXT;
                                return /* self */;
                        case RS_SELF:

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

Reply via email to