Skip to content

Commit 20ac74d

Browse files
nielsdoscharmitro
authored andcommitted
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 phpGH-17534.
1 parent e9d5549 commit 20ac74d

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
@@ -3753,6 +3753,12 @@ static uint32_t zend_compile_args(
37533753
"Cannot use argument unpacking after named arguments");
37543754
}
37553755

3756+
/* Unpack may contain named arguments. */
3757+
may_have_undef = 1;
3758+
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
3759+
*may_have_extra_named_args = 1;
3760+
}
3761+
37563762
uses_arg_unpack = 1;
37573763
fbc = NULL;
37583764

@@ -3761,11 +3767,6 @@ static uint32_t zend_compile_args(
37613767
opline->op2.num = arg_count;
37623768
opline->result.var = EX_NUM_TO_VAR(arg_count - 1);
37633769

3764-
/* Unpack may contain named arguments. */
3765-
may_have_undef = 1;
3766-
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
3767-
*may_have_extra_named_args = 1;
3768-
}
37693770
continue;
37703771
}
37713772

0 commit comments

Comments
 (0)