diff --git a/Zend/tests/closure_063.phpt b/Zend/tests/closure_063.phpt new file mode 100644 index 00000000000..b53f370eb4b --- /dev/null +++ b/Zend/tests/closure_063.phpt @@ -0,0 +1,12 @@ +--TEST-- +Closure::bindTo leaks with "fake" closure +--FILE-- +bindTo(new stdClass); +?> +DONE +--EXPECT-- +DONE \ No newline at end of file diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index a5ae8cde359..b5c0b475532 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -770,7 +770,8 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) { - zend_create_closure_ex(res, func, scope, called_scope, this_ptr, /* is_fake */ false); + zend_create_closure_ex(res, func, scope, called_scope, this_ptr, + /* is_fake */ (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) != 0); } ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) /* {{{ */