Skip to content

Commit a1953d5

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 12abb1f commit a1953d5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

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)