From 02bd933b1e15de1d28860b4c01d0cd3a8447607f Mon Sep 17 00:00:00 2001 From: Aart Stuurman Date: Tue, 28 Jul 2015 11:37:11 +0200 Subject: fixed memory leak when using magic casting functions like __toInteger --- zend/classimpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zend/classimpl.cpp b/zend/classimpl.cpp index 4a9b0b7..71b85e5 100644 --- a/zend/classimpl.cpp +++ b/zend/classimpl.cpp @@ -476,6 +476,9 @@ int ClassImpl::cast(zval *val, zval *retval, int type TSRMLS_DC) // @todo do we turn into endless conversion if the __toString object returns 'this' ?? // (and if it does: who cares? If the extension programmer is stupid, why do we have to suffer?) + + // increment refcount for "result" (we keep a reference here) + Z_ADDREF_P(result); // is the original parameter overwritten? if (val == retval) zval_dtor(val); -- cgit v1.2.3