From c599d173aba6f232d47fbe16386d9edeba658815 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sat, 30 May 2020 23:33:25 +0200 Subject: [PATCH] Fix php_get_args function info return type and add arg check Closes GH-5648. --- Zend/tests/bug72107.phpt | 2 +- Zend/zend_builtin_functions.c | 2 ++ ext/opcache/Optimizer/zend_func_info.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Zend/tests/bug72107.phpt b/Zend/tests/bug72107.phpt index c22f657ebb..b37ecf0849 100644 --- a/Zend/tests/bug72107.phpt +++ b/Zend/tests/bug72107.phpt @@ -13,4 +13,4 @@ try { } ?> --EXPECT-- -Cannot call func_get_args() dynamically +func_get_args() expects exactly 0 parameters, 4 given diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 9062cf6f5c..775bab1504 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -231,6 +231,8 @@ ZEND_FUNCTION(func_get_args) uint32_t i; zend_execute_data *ex = EX(prev_execute_data); + ZEND_PARSE_PARAMETERS_NONE(); + if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) { zend_throw_error(NULL, "func_get_args() cannot be called from the global scope"); RETURN_THROWS(); diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 6b013f7614..3b9ebf75ab 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -94,7 +94,7 @@ static const func_info_t func_infos[] = { /* zend */ F1("zend_version", MAY_BE_STRING), FN("func_get_arg", UNKNOWN_INFO), - FN("func_get_args", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY), + FN("func_get_args", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY), F1("get_class_vars", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF), FN("get_object_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF), FN("get_mangled_object_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF), -- 2.40.0