From: Nikita Popov Date: Sat, 16 Apr 2016 12:47:27 +0000 (+0200) Subject: Don't copy args in Closure::__invoke() X-Git-Tag: php-7.1.0alpha1~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c5861e6c650a2d6b8044151b2f71b6b6fcc024c;p=php Don't copy args in Closure::__invoke() --- diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index ce392e61ba..a00d000e6e 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -52,17 +52,11 @@ static zend_object_handlers closure_handlers; ZEND_METHOD(Closure, __invoke) /* {{{ */ { zend_function *func = EX(func); - zval *arguments; + zval *arguments = ZEND_CALL_ARG(execute_data, 1); - arguments = emalloc(sizeof(zval) * ZEND_NUM_ARGS()); - if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) { - efree(arguments); - zend_throw_error(NULL, "Cannot get arguments for calling closure"); - RETVAL_FALSE; - } else if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) { + if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) { RETVAL_FALSE; } - efree(arguments); /* destruct the function also, then - we have allocated it in get_method */ zend_string_release(func->internal_function.function_name);