Skip to content

Commit

Permalink
Simplify zend_forbid_dynamic_call() (#7443)
Browse files Browse the repository at this point in the history
The special cases (parse_str/mb_parse_str with a single argument) have been removed completely, we can simplify it now.
  • Loading branch information
twose authored Sep 1, 2021
1 parent f3fa9fb commit a13730c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,13 @@ ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force);
ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force);

static zend_always_inline zend_result zend_forbid_dynamic_call(const char *func_name)
static zend_always_inline zend_result zend_forbid_dynamic_call(void)
{
zend_execute_data *ex = EG(current_execute_data);
ZEND_ASSERT(ex != NULL && ex->func != NULL);

if (ZEND_CALL_INFO(ex) & ZEND_CALL_DYNAMIC) {
zend_throw_error(NULL, "Cannot call %s dynamically", func_name);
zend_throw_error(NULL, "Cannot call %s() dynamically", get_active_function_name());
return FAILURE;
}

Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ ZEND_FUNCTION(func_num_args)
RETURN_THROWS();
}

if (zend_forbid_dynamic_call("func_num_args()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
RETURN_LONG(-1);
}

Expand Down Expand Up @@ -188,7 +188,7 @@ ZEND_FUNCTION(func_get_arg)
RETURN_THROWS();
}

if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -226,7 +226,7 @@ ZEND_FUNCTION(func_get_args)
RETURN_THROWS();
}

if (zend_forbid_dynamic_call("func_get_args()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -1331,7 +1331,7 @@ ZEND_FUNCTION(get_defined_vars)

ZEND_PARSE_PARAMETERS_NONE();

if (zend_forbid_dynamic_call("get_defined_vars()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ PHP_FUNCTION(extract)
}
}

if (zend_forbid_dynamic_call("extract()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
return;
}

Expand Down Expand Up @@ -2523,7 +2523,7 @@ PHP_FUNCTION(compact)
Z_PARAM_VARIADIC('+', args, num_args)
ZEND_PARSE_PARAMETERS_END();

if (zend_forbid_dynamic_call("compact()") == FAILURE) {
if (zend_forbid_dynamic_call() == FAILURE) {
return;
}

Expand Down

0 comments on commit a13730c

Please sign in to comment.