]> granicus.if.org Git - php/commitdiff
Closure::fromCallable() supports only regular methods and magic method invoked throug...
authorDmitry Stogov <dmitry@zend.com>
Mon, 11 Mar 2019 12:39:34 +0000 (15:39 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 11 Mar 2019 12:39:34 +0000 (15:39 +0300)
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.

Zend/zend_closures.c

index 065034cc9e43a5b49c8751698e7e7ba5899b4d70..70b70d9723952ec443d51b75f4011516a967440c 100644 (file)
@@ -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;