Skip to content

Commit 5c058d7

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-10801: Named arguments in CTE functions cause a segfault
2 parents 779ab32 + c450842 commit 5c058d7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Zend/Optimizer/sccp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,8 +1646,9 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
16461646
break;
16471647
}
16481648

1649-
/* We're only interested in functions with up to three arguments right now */
1650-
if (call->num_args > 3 || call->send_unpack || call->is_prototype) {
1649+
/* We're only interested in functions with up to three arguments right now.
1650+
* Note that named arguments with the argument in declaration order will still work. */
1651+
if (call->num_args > 3 || call->send_unpack || call->is_prototype || call->named_args) {
16511652
SET_RESULT_BOT(result);
16521653
break;
16531654
}

ext/opcache/tests/opt/gh10801.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-10801 (Named arguments in CTE functions cause a segfault)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=0xe0
7+
--EXTENSIONS--
8+
opcache
9+
--FILE--
10+
<?php
11+
// Named argument case and does not do CTE as expected
12+
print_r(array_keys(array: [1 => 1], strict: true, filter_value: 0));
13+
// Will not use named arguments and do CTE as expected
14+
print_r(array_keys(array: [1 => 1], filter_value: 0, strict: true));
15+
?>
16+
--EXPECT--
17+
Array
18+
(
19+
)
20+
Array
21+
(
22+
)

0 commit comments

Comments
 (0)