Skip to content

Commit

Permalink
Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nielsdos committed Jan 21, 2025
1 parent 5344bcc commit 0b3e637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PHP NEWS
. Fixed potential OOB when checking for trailing spaces on Windows. (cmb)
. Fixed bug GH-17408 (Assertion failure Zend/zend_exceptions.c).
(nielsdos, ilutov)
. Fix may_have_extra_named_args flag for ZEND_AST_UNPACK. (nielsdos)

- DOM:
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).
Expand Down
11 changes: 6 additions & 5 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3661,6 +3661,12 @@ static uint32_t zend_compile_args(
"Cannot use argument unpacking after named arguments");
}

/* Unpack may contain named arguments. */
may_have_undef = 1;
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
*may_have_extra_named_args = 1;
}

uses_arg_unpack = 1;
fbc = NULL;

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

/* Unpack may contain named arguments. */
may_have_undef = 1;
if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
*may_have_extra_named_args = 1;
}
continue;
}

Expand Down

0 comments on commit 0b3e637

Please sign in to comment.