]> granicus.if.org Git - php/commitdiff
Fixed reference counting
authorDmitry Stogov <dmitry@zend.com>
Thu, 22 Mar 2012 10:38:38 +0000 (14:38 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 22 Mar 2012 11:03:16 +0000 (15:03 +0400)
ext/spl/spl_directory.c

index fb198236e5ef341b981c2fbefd538546d6aeb2d8..9d454c94bb1af5013a87225a6efb87412e9b38ae 100755 (executable)
@@ -1644,8 +1644,8 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval
                /* ->current must be initialized; rewind doesn't set it and valid
                 * doesn't check whether it's set */
                iterator->current = object;
+               Z_SET_REFCOUNT_P(object, Z_REFCOUNT_P(object) + 2);
        }
-       zval_add_ref(&object);
        
        return (zend_object_iterator*)iterator;
 }
@@ -1847,8 +1847,8 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
        if (iterator->intern.data == NULL) {
                iterator->intern.data = object;
                iterator->intern.funcs = &spl_filesystem_tree_it_funcs;
+               zval_add_ref(&object);
        }
-       zval_add_ref(&object);
        
        return (zend_object_iterator*)iterator;
 }