From 9882265024f528bd22e161eb15e2999968b4bc22 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 22 Sep 2025 15:24:19 +0100 Subject: [PATCH 1/2] ext/filter: Check callback validity once 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 --- ext/filter/callback_filter.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index 719b66767980f..20bb8152a94b0 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -19,22 +19,21 @@ zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { zval retval; - int status; + zend_fcall_info_cache fcc = {}; - if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL)) { + if (!option_array || !zend_is_callable_ex(option_array, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) { zend_type_error("%s(): Option must be a valid callback", get_active_function_name()); zval_ptr_dtor(value); ZVAL_NULL(value); return SUCCESS; } - status = call_user_function(NULL, NULL, option_array, &retval, 1, value); + zend_call_known_fcc(&fcc, &retval, 1, value, NULL); + zval_ptr_dtor(value); - if (status == SUCCESS && !Z_ISUNDEF(retval)) { - zval_ptr_dtor(value); + if (!Z_ISUNDEF(retval)) { ZVAL_COPY_VALUE(value, &retval); } else { - zval_ptr_dtor(value); ZVAL_NULL(value); } return SUCCESS; From 14ba46b1f68088216ece793f8739854ebd89535e Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 30 Sep 2025 14:42:18 +0100 Subject: [PATCH 2/2] Addres review comment --- ext/filter/callback_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index 20bb8152a94b0..dea39c6cc7c30 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -19,7 +19,7 @@ zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { zval retval; - zend_fcall_info_cache fcc = {}; + zend_fcall_info_cache fcc; if (!option_array || !zend_is_callable_ex(option_array, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) { zend_type_error("%s(): Option must be a valid callback", get_active_function_name());