Skip to content

Commit 0b3e637

Browse files
committed
Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
The check for `!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)` is performed after `fbc` is set to NULL, so this always returns true. This results in `ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS` always being set for unpack sends. Fix it by moving the flag updates to the point before setting `fbc` to NULL. Closes GH-17534.
1 parent 5344bcc commit 0b3e637

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP NEWS
1414
. Fixed potential OOB when checking for trailing spaces on Windows. (cmb)
1515
. Fixed bug GH-17408 (Assertion failure Zend/zend_exceptions.c).
1616
(nielsdos, ilutov)
17+
. Fix may_have_extra_named_args flag for ZEND_AST_UNPACK. (nielsdos)
1718

1819
- DOM:
1920
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).

Zend/zend_compile.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,6 +3661,12 @@ static uint32_t zend_compile_args(
36613661
"Cannot use argument unpacking after named arguments");
36623662
}
36633663

3664+
/* Unpack may contain named arguments. */
3665+
may_have_undef = 1;
3666+
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
3667+
*may_have_extra_named_args = 1;
3668+
}
3669+
36643670
uses_arg_unpack = 1;
36653671
fbc = NULL;
36663672

@@ -3669,11 +3675,6 @@ static uint32_t zend_compile_args(
36693675
opline->op2.num = arg_count;
36703676
opline->result.var = EX_NUM_TO_VAR(arg_count - 1);
36713677

3672-
/* Unpack may contain named arguments. */
3673-
may_have_undef = 1;
3674-
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
3675-
*may_have_extra_named_args = 1;
3676-
}
36773678
continue;
36783679
}
36793680

0 commit comments

Comments
 (0)