Skip to content

Commit f26b60a

Browse files
committed
Fix crash when unpacking into array literal with string keys
1 parent 6627f78 commit f26b60a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Using array unpacking in an array literal that also has string keys (OSS-Fuzz #17965)
3+
--FILE--
4+
<?php
5+
$y = [1, 2, 3];
6+
$z = "bar";
7+
$x = [...$y, "foo" => $z];
8+
var_dump($x);
9+
?>
10+
--EXPECT--
11+
array(4) {
12+
[0]=>
13+
int(1)
14+
[1]=>
15+
int(2)
16+
[2]=>
17+
int(3)
18+
["foo"]=>
19+
string(3) "bar"
20+
}

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7888,6 +7888,7 @@ void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
78887888
if (elem_ast->kind == ZEND_AST_UNPACK) {
78897889
zend_compile_expr(&value_node, value_ast);
78907890
if (i == 0) {
7891+
opnum_init = get_next_op_number();
78917892
opline = zend_emit_op_tmp(result, ZEND_INIT_ARRAY, NULL, NULL);
78927893
}
78937894
opline = zend_emit_op(NULL, ZEND_ADD_ARRAY_UNPACK, &value_node, NULL);

0 commit comments

Comments
 (0)