Skip to content

Fix GH-10801: Named arguments in CTE functions cause a segfault #10811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,9 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
break;
}

/* We're only interested in functions with up to three arguments right now */
if (call->num_args > 3 || call->send_unpack || call->is_prototype) {
/* We're only interested in functions with up to three arguments right now.
* Note that named arguments with the argument in declaration order will still work. */
if (call->num_args > 3 || call->send_unpack || call->is_prototype || call->named_args) {
SET_RESULT_BOT(result);
break;
}
Expand Down
22 changes: 22 additions & 0 deletions ext/opcache/tests/opt/gh10801.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
GH-10801 (Named arguments in CTE functions cause a segfault)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=0xe0
--EXTENSIONS--
opcache
--FILE--
<?php
// Named argument case and does not do CTE as expected
print_r(array_keys(array: [1 => 1], strict: true, filter_value: 0));
// Will not use named arguments and do CTE as expected
print_r(array_keys(array: [1 => 1], filter_value: 0, strict: true));
?>
--EXPECT--
Array
(
)
Array
(
)