From 1b5b21539f8f12e6114bd4852438101c8989eabc Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 14 Oct 2015 12:07:04 +0200 Subject: Do not create a fake Closure for real Closures That is solved by just returning the Closure as is, which is safe due to Closures being immutable objects --- ext/reflection/php_reflection.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a095120e18..df905bf5cc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1762,7 +1762,12 @@ ZEND_METHOD(reflection_function, getClosure) } GET_REFLECTION_OBJECT_PTR(fptr); - zend_create_fake_closure(return_value, fptr, NULL, NULL, NULL); + if (!Z_ISUNDEF(intern->obj)) { + /* Closures are immutable objects */ + ZVAL_COPY(return_value, &intern->obj); + } else { + zend_create_fake_closure(return_value, fptr, NULL, NULL, NULL); + } } /* }}} */ -- cgit v1.2.1