[php-src] master: Merge branch 'PHP-8.6'
| From: | ndossche | Date: | Fri, 25 Sep 2026 08:42:21 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141531@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-09-25T10:42:12+02:00
Commit: https://github.com/php/php-src/commit/8991945a49ea5b58506ad1b1ad47eca071908ce8
Raw diff: https://github.com/php/php-src/commit/8991945a49ea5b58506ad1b1ad47eca071908ce8.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
Fix OSS-Fuzz #565486253: coerced arg with '...' on non-variadic function
Changed paths:
A Zend/tests/partial_application/const_arg_opt_004.phpt
M Zend/zend_partial.c
Diff:
diff --git a/Zend/tests/partial_application/const_arg_opt_004.phpt
b/Zend/tests/partial_application/const_arg_opt_004.phpt
new file mode 100644
index 000000000000..f80c14dc6abd
--- /dev/null
+++ b/Zend/tests/partial_application/const_arg_opt_004.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Constant argument optimization - coerced arg with '...' on non-variadic function
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--FILE--
+<?php
+function g(string $s, $x = 1) {
+ var_dump($s, func_get_args());
+}
+
+$f = g(15, ...);
+$f();
+$f(2, 3);
+
+?>
+--EXPECT--
+string(2) "15"
+array(2) {
+ [0]=>
+ string(2) "15"
+ [1]=>
+ int(1)
+}
+string(2) "15"
+array(3) {
+ [0]=>
+ string(2) "15"
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c
index 1f74830b900e..e938f53cc3cf 100644
--- a/Zend/zend_partial.c
+++ b/Zend/zend_partial.c
@@ -566,7 +566,10 @@ static zend_ast *zp_compile_forwarding_call(
ZEND_ASSERT(!Z_REFCOUNTED(argv[offset]));
/* This argument never changes, so we can burn it into the op_array
- * and check its type ahead of time. */
+ * and check its type ahead of time.
+ * Work with a value copy because a scalar type check may coerce this value. */
+ zval value;
+ ZVAL_COPY_VALUE(&value, &argv[offset]);
zend_arg_info *arg_info;
if (offset < function->common.num_args) {
@@ -577,18 +580,18 @@ static zend_ast *zp_compile_forwarding_call(
arg_info = NULL;
}
if (arg_info && ZEND_TYPE_IS_SET(arg_info->type)
- && UNEXPECTED(!zend_check_type_ex(&arg_info->type, &argv[offset],
+ && UNEXPECTED(!zend_check_type_ex(&arg_info->type, &value,
/* current_frame */ true, /* is_internal */ false))) {
zend_string *need_msg = zend_type_to_string_resolved(arg_info->type,
function->common.scope);
zend_argument_type_error_ex(function, offset + 1,
"must be of type %s, %s given",
- ZSTR_VAL(need_msg), zend_zval_value_name(&argv[offset]));
+ ZSTR_VAL(need_msg), zend_zval_value_name(&value));
zend_string_release(need_msg);
goto error;
}
- args_ast = zend_ast_list_add(args_ast, zend_ast_create_zval(&argv[offset]));
+ args_ast = zend_ast_list_add(args_ast, zend_ast_create_zval(&value));
} else {
args_ast = zend_ast_list_add(args_ast, zend_ast_create(ZEND_AST_VAR,
zend_ast_create_zval_from_str(zend_string_copy(var_names->params[offset]))));