summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAart Stuurman <aart.stuurman@copernica.com>2015-07-28 11:32:19 +0200
committerAart Stuurman <aart.stuurman@copernica.com>2015-07-28 11:32:19 +0200
commit544503eb03ec80c32f347aa9db664e5d2dd8c013 (patch)
treec6368616c60dad840d3b198a1cc833b3524e4068
parent852dce11277755735d10c8ccb84a23f615792655 (diff)
fixed memory leak when iterating over a Php::Traversable object
-rw-r--r--zend/iteratorimpl.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/zend/iteratorimpl.cpp b/zend/iteratorimpl.cpp
index 2750ddb..3bd2ed7 100644
--- a/zend/iteratorimpl.cpp
+++ b/zend/iteratorimpl.cpp
@@ -82,7 +82,10 @@ void IteratorImpl::key(zend_object_iterator *iter, zval *key TSRMLS_DC)
// detach the underlying zval
zval *val = retval.detach();
-
+
+ // increment number of references of the zval (we keep a copy too)
+ Z_ADDREF_P(val);
+
// copy it to the key
ZVAL_ZVAL(key, val, 1, 1);
}