Skip to content

Commit a85bb8b

Browse files
committed
Drop usage of confusing zend_fcall_info_call() API
The last parameter which is named zval *args, does NOT set the FCI params field. It is expected to be a PHP array which gets looped over to set the arguments which is also a zval pointer... Since PHP 8.0, the named_params field is a more appropriate way of doing this.
1 parent 3044af2 commit a85bb8b

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

ext/spl/spl_iterators.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3221,7 +3221,9 @@ static int spl_iterator_func_apply(zend_object_iterator *iter, void *puser) /* {
32213221
int result;
32223222

32233223
apply_info->count++;
3224-
zend_fcall_info_call(&apply_info->fci, &apply_info->fcc, &retval, NULL);
3224+
3225+
apply_info->fci.retval = &retval;
3226+
zend_call_function(&apply_info->fci, &apply_info->fcc);
32253227
result = zend_is_true(&retval) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_STOP;
32263228
zval_ptr_dtor(&retval);
32273229
return result;

main/output.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -939,15 +939,21 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
939939

940940
OG(running) = handler;
941941
if (handler->flags & PHP_OUTPUT_HANDLER_USER) {
942-
zval retval, ob_data, ob_mode;
942+
zval ob_args[2];
943+
zval retval;
943944

944-
ZVAL_STRINGL(&ob_data, handler->buffer.data, handler->buffer.used);
945-
ZVAL_LONG(&ob_mode, (zend_long) context->op);
946-
zend_fcall_info_argn(&handler->func.user->fci, 2, &ob_data, &ob_mode);
947-
zval_ptr_dtor(&ob_data);
945+
/* ob_data */
946+
ZVAL_STRINGL(&ob_args[0], handler->buffer.data, handler->buffer.used);
947+
/* ob_mode */
948+
ZVAL_LONG(&ob_args[1], (zend_long) context->op);
949+
950+
/* Set FCI info */
951+
handler->func.user->fci.param_count = 2;
952+
handler->func.user->fci.params = ob_args;
953+
handler->func.user->fci.retval = &retval;
948954

949955
#define PHP_OUTPUT_USER_SUCCESS(retval) ((Z_TYPE(retval) != IS_UNDEF) && !(Z_TYPE(retval) == IS_FALSE))
950-
if (SUCCESS == zend_fcall_info_call(&handler->func.user->fci, &handler->func.user->fcc, &retval, NULL) && PHP_OUTPUT_USER_SUCCESS(retval)) {
956+
if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && PHP_OUTPUT_USER_SUCCESS(retval)) {
951957
/* user handler may have returned TRUE */
952958
status = PHP_OUTPUT_HANDLER_NO_DATA;
953959
if (Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) {
@@ -964,7 +970,9 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
964970
status = PHP_OUTPUT_HANDLER_FAILURE;
965971
}
966972

967-
zend_fcall_info_argn(&handler->func.user->fci, 0);
973+
/* Free arguments and return value */
974+
zval_ptr_dtor(&ob_args[0]);
975+
zval_ptr_dtor(&ob_args[1]);
968976
zval_ptr_dtor(&retval);
969977

970978
} else {

0 commit comments

Comments
 (0)