Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c7da728

Browse files
authored
ext/filter: Check callback validity once (#19921)
The call_user_function() API redoes the zend_is_callable() check, which has been just done. We can check validity and retrieve the FCC to call it directly rather than having a useless double check
1 parent 44714a3 commit c7da728

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎ext/filter/callback_filter.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@
1919
zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
2020
{
2121
zval retval;
22-
intstatus;
22+
zend_fcall_info_cachefcc;
2323

24-
if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL)) {
24+
if (!option_array || !zend_is_callable_ex(option_array, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) {
2525
zend_type_error("%s(): Option must be a valid callback", get_active_function_name());
2626
zval_ptr_dtor(value);
2727
ZVAL_NULL(value);
2828
return SUCCESS;
2929
}
3030

31-
status = call_user_function(NULL, NULL, option_array, &retval, 1, value);
31+
zend_call_known_fcc(&fcc, &retval, 1, value, NULL);
32+
zval_ptr_dtor(value);
3233

33-
if (status == SUCCESS && !Z_ISUNDEF(retval)) {
34-
zval_ptr_dtor(value);
34+
if (!Z_ISUNDEF(retval)) {
3535
ZVAL_COPY_VALUE(value, &retval);
3636
} else {
37-
zval_ptr_dtor(value);
3837
ZVAL_NULL(value);
3938
}
4039
return SUCCESS;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /