com php-src: Fix crash when unpacking into array literal with string keys: Zend/tests/array_unpack_string_keys.phpt Zend/zend_ compile.c

From: Date: Fri, 04 Oct 2019 08:11:30 +0000
Subject: com php-src: Fix crash when unpacking into array literal with string keys: Zend/tests/array_unpack_string_keys.phpt Zend/zend_ compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108718@lists.php.net to get a copy of this message
Commit: f26b60a583efb064a8c082b780b9b186c43cac64 Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 4 Oct 2019 10:11:30 +0200 Parents: 6627f782d66173a1412e6a9f721fe99f91cd9a0a Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f26b60a583efb064a8c082b780b9b186c43cac64 Log: Fix crash when unpacking into array literal with string keys Changed paths: A Zend/tests/array_unpack_string_keys.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/array_unpack_string_keys.phpt b/Zend/tests/array_unpack_string_keys.phpt new file mode 100644 index 00000000000..ce84a8e21da --- /dev/null +++ b/Zend/tests/array_unpack_string_keys.phpt @@ -0,0 +1,20 @@ +--TEST-- +Using array unpacking in an array literal that also has string keys (OSS-Fuzz #17965) +--FILE-- +<?php +$y = [1, 2, 3]; +$z = "bar"; +$x = [...$y, "foo" => $z]; +var_dump($x); +?> +--EXPECT-- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + ["foo"]=> + string(3) "bar" +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 85e3216e24a..8f545ce51fa 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7888,6 +7888,7 @@ void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */ if (elem_ast->kind == ZEND_AST_UNPACK) { zend_compile_expr(&value_node, value_ast); if (i == 0) { + opnum_init = get_next_op_number(); opline = zend_emit_op_tmp(result, ZEND_INIT_ARRAY, NULL, NULL); } opline = zend_emit_op(NULL, ZEND_ADD_ARRAY_UNPACK, &value_node, NULL);

« previous php.cvs (#108718) next »