diff --git a/Zend/tests/fake_closure_in_internal_func_leaks.phpt b/Zend/tests/fake_closure_in_internal_func_leaks.phpt new file mode 100644 index 00000000000..e12b4b6253f --- /dev/null +++ b/Zend/tests/fake_closure_in_internal_func_leaks.phpt @@ -0,0 +1,15 @@ +--TEST-- +Fake closure called from internal function leaks +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + array(0) { + } +} diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 82c38366d89..0d9c357b463 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -973,6 +973,10 @@ cleanup_args: zend_interrupt_function(EG(current_execute_data)); } } + + if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS)) { + OBJ_RELEASE(Z_OBJ(call->This)); + } } EG(fake_scope) = orig_fake_scope;