Skip to content

Commit

Permalink
Fix incorrect access of AST_UNPACK
Browse files Browse the repository at this point in the history
list_is_keyed() did not take into account that there may be
AST_UNPACK elements. These would error lateron anyway, but still
produce an invalid access here.
  • Loading branch information
nikic committed Oct 12, 2021
1 parent c5e030f commit f555544
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Zend/tests/array_unpack/in_destructuring_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Spread operator is not supported in destructuring assignments (only spread)
--FILE--
<?php

[...$x] = [1, 2, 3];

?>
--EXPECTF--
Fatal error: Spread operator is not supported in assignments in %s on line %d
5 changes: 3 additions & 2 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3006,8 +3006,9 @@ static bool zend_propagate_list_refs(zend_ast *ast) { /* {{{ */
static bool list_is_keyed(zend_ast_list *list)
{
for (uint32_t i = 0; i < list->children; i++) {
if (list->child[i]) {
return list->child[i]->child[1] != NULL;
zend_ast *child = list->child[i];
if (child) {
return child->kind == ZEND_AST_ARRAY_ELEM && child->child[1] != NULL;
}
}
return false;
Expand Down

0 comments on commit f555544

Please sign in to comment.