Skip to content

Commit f555544

Browse files
committed
Fix incorrect access of AST_UNPACK
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.
1 parent c5e030f commit f555544

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Spread operator is not supported in destructuring assignments (only spread)
3+
--FILE--
4+
<?php
5+
6+
[...$x] = [1, 2, 3];
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Spread operator is not supported in assignments in %s on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,8 +3006,9 @@ static bool zend_propagate_list_refs(zend_ast *ast) { /* {{{ */
30063006
static bool list_is_keyed(zend_ast_list *list)
30073007
{
30083008
for (uint32_t i = 0; i < list->children; i++) {
3009-
if (list->child[i]) {
3010-
return list->child[i]->child[1] != NULL;
3009+
zend_ast *child = list->child[i];
3010+
if (child) {
3011+
return child->kind == ZEND_AST_ARRAY_ELEM && child->child[1] != NULL;
30113012
}
30123013
}
30133014
return false;

0 commit comments

Comments
 (0)