summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-12-20 12:41:38 +0000
committerAntony Dovgal <tony2001@php.net>2005-12-20 12:41:38 +0000
commit320b5ce4614b6a8feaba646b0c08af2c393cdd49 (patch)
treeafb11bf8e9f4cc1d6b92d4ae60f5fefde237f91d
parent3ba24546ed77bcfda2ee877f6cf1e2e3d51fea70 (diff)
downloadphp-git-320b5ce4614b6a8feaba646b0c08af2c393cdd49.tar.gz
MFB: more SPL leak fixes
-rwxr-xr-xext/spl/spl_iterators.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 5871edc9b6..86da1a5fa8 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -372,6 +372,7 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
zval *iterator;
zend_class_entry *ce_iterator;
long mode = RIT_LEAVES_ONLY, flags = 0;
+ int inc_refcount = 1;
php_set_error_handling(EH_THROW, U_CLASS_ENTRY(spl_ce_InvalidArgumentException) TSRMLS_CC);
@@ -379,6 +380,7 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
if (instanceof_function(Z_OBJCE_P(iterator), U_CLASS_ENTRY(zend_ce_aggregate) TSRMLS_CC)) {
zval *aggregate = iterator;
zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator);
+ inc_refcount = 0;
}
} else {
iterator = NULL;
@@ -428,7 +430,9 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
}
ce_iterator = Z_OBJCE_P(iterator); /* respect inheritance, don't use spl_ce_RecursiveIterator */
intern->iterators[0].iterator = ce_iterator->get_iterator(ce_iterator, iterator TSRMLS_CC);
- iterator->refcount++;
+ if (inc_refcount) {
+ iterator->refcount++;
+ }
intern->iterators[0].zobject = iterator;
intern->iterators[0].ce = ce_iterator;
intern->iterators[0].state = RS_START;