com php-src: Fixed bug #72441 (Segmentation fault: RFC list_keys): NEWS Zend/tests/bug72441.phpt Zend/zend_compile.c
| From: | Xinchen Hui | Date: | Fri, 17 Jun 2016 16:34:15 +0000 |
| Subject: | com php-src: Fixed bug #72441 (Segmentation fault: RFC list_keys): NEWS Zend/tests/bug72441.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92425@lists.php.net to get a copy of this message | ||
Commit: fcd8a5ca65452db19ca8ef197fa63a1ec9c2f0a0
Author: Xinchen Hui <laruence@gmail.com> Fri, 17 Jun 2016 09:34:15 -0700
Parents: 08f0345d0a25684c9b5e9e7587ab6ed22a4dfd4b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fcd8a5ca65452db19ca8ef197fa63a1ec9c2f0a0
Log:
Fixed bug #72441 (Segmentation fault: RFC list_keys)
Bugs:
https://bugs.php.net/72441
Changed paths:
M NEWS
A Zend/tests/bug72441.phpt
M Zend/zend_compile.c
Diff:
diff --git a/NEWS b/NEWS
index fbc281c..f672934 100644
--- a/NEWS
+++ b/NEWS
@@ -3,9 +3,10 @@ PHP NEWS
?? ??? 2016, PHP 7.1.0alpha2
- Core:
- . Implemented RFC: Replace "Missing argument" warning with "Too few
+ . Implemented RFC: R/eplace "Missing argument" warning with "Too few
arguments" exception. (Dmitry)
. Implemented RFC: Fix inconsistent behavior of $this variable. (Dmitry)
+ . Fixed bug #72441 (Segmentation fault: RFC list_keys). (Laruence)
. Fixed bug #72395 (list() regression). (Laruence)
. Fixed bug #72373 (TypeError after Generator function w/declared return type
finishes). (Nikita)
diff --git a/Zend/tests/bug72441.phpt b/Zend/tests/bug72441.phpt
new file mode 100644
index 0000000..af57b3a
--- /dev/null
+++ b/Zend/tests/bug72441.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #72441 (Segmentation fault: RFC list_keys)
+--FILE--
+<?php
+
+$array = [];
+
+list(
+ '' => $foo,
+ $bar
+) = $array;
+?>
+--EXPECTF--
+Fatal error: Cannot mix keyed and unkeyed array entries in assignments in %sbug72441.php on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 02507f2..1d544c6 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2819,6 +2819,10 @@ static void zend_compile_keyed_list_assign(zend_ast_list *list, znode
*expr_node
zend_error(E_COMPILE_ERROR, "[] and list() assignments cannot be by reference");
}
+ if (key_ast == NULL) {
+ zend_error(E_COMPILE_ERROR, "Cannot mix keyed and unkeyed array entries in
assignments");
+ }
+
zend_compile_expr(&dim_node, key_ast);
if (expr_node->op_type == IS_CONST) {
@@ -2829,10 +2833,6 @@ static void zend_compile_keyed_list_assign(zend_ast_list *list, znode
*expr_node
zend_error(E_COMPILE_ERROR, "Cannot use empty array entries in keyed array");
}
- if (key_ast == NULL) {
- zend_error(E_COMPILE_ERROR, "Cannot mix keyed and unkeyed array entries in
assignments");
- }
-
zend_verify_list_assign_target(var_ast, old_style);
zend_emit_op(&fetch_result, ZEND_FETCH_LIST, expr_node, &dim_node);