com php-src: Closure::fromCallable() supports only regular methods and magic method invoked through __call()/__callStatic (). It doesn't support
method of internal classes invoked through C object or class hand lers. This commit prevents crash described at b ug #77708, but doesn't implement
the desired behavior.: Zend/zend_closures.c
| From: | Dmitry Stogov | Date: | Mon, 11 Mar 2019 12:39:34 +0000 |
| Subject: | com php-src: Closure::fromCallable() supports only regular methods and magic method invoked through __call()/__callStatic (). It doesn't support method of internal classes invoked through C object or class hand lers. This commit prevents crash described at b ug #77708, but doesn't implement the desired behavior.: Zend/zend_closures.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105077@lists.php.net to get a copy of this message | ||
Commit: 409e0dd29f3163490b6e27661e5c79c93b57e98b
Author: Dmitry Stogov <dmitry@zend.com> Mon, 11 Mar 2019 15:39:34 +0300
Parents: e7f0a60d54d4c6820141251b51f62d8c3424d467
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=409e0dd29f3163490b6e27661e5c79c93b57e98b
Log:
Closure::fromCallable() supports only regular methods and magic method invoked through
__call()/__callStatic().
It doesn't support method of internal classes invoked through C object or class handlers.
This commit prevents crash described at bug #77708, but doesn't implement the desired behavior.
Bugs:
https://bugs.php..net/77708
Changed paths:
M Zend/zend_closures.c
Diff:
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 065034c..70b70d9 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -280,6 +280,19 @@ static int zend_create_closure_from_callable(zval *return_value, zval
*callable,
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
memset(&call, 0, sizeof(zend_internal_function));
+ if (!mptr->common.scope) {
+ return FAILURE;
+ }
+ if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
+ if (!mptr->common.scope->__callstatic) {
+ return FAILURE;
+ }
+ } else {
+ if (!mptr->common.scope->__call) {
+ return FAILURE;
+ }
+ }
+
call.type = ZEND_INTERNAL_FUNCTION;
call.fn_flags = mptr->common.fn_flags & ZEND_ACC_STATIC;
call.handler = zend_closure_call_magic;