mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
PHP must not create circular arrays when element is assigned by value.
This commit is contained in:
parent
eb4342eb14
commit
edc7c8ccfa
@ -14,20 +14,19 @@ $a[0][0] = $a;
|
||||
debug_zval_dump($a);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) refcount(%d){
|
||||
array(1) refcount(2){
|
||||
[0]=>
|
||||
array(1) refcount(%d){
|
||||
[0]=>
|
||||
*RECURSION*
|
||||
array(0) refcount(1){
|
||||
}
|
||||
}
|
||||
array(1) refcount(%d){
|
||||
array(1) refcount(2){
|
||||
[0]=>
|
||||
array(1) refcount(%d){
|
||||
array(1) refcount(1){
|
||||
[0]=>
|
||||
array(1) refcount(%d){
|
||||
array(1) refcount(1){
|
||||
[0]=>
|
||||
*RECURSION*
|
||||
array(0) refcount(1){
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3000,7 +3000,13 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
|
||||
if (zend_is_assign_to_self(var_ast, expr_ast)
|
||||
&& !is_this_fetch(expr_ast)) {
|
||||
/* $a[0] = $a should evaluate the right $a first */
|
||||
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
|
||||
znode cv_node;
|
||||
|
||||
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
|
||||
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
|
||||
} else {
|
||||
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
|
||||
}
|
||||
} else {
|
||||
zend_compile_expr(&expr_node, expr_ast);
|
||||
}
|
||||
@ -3023,7 +3029,13 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
|
||||
case ZEND_AST_ARRAY:
|
||||
if (zend_list_has_assign_to_self(var_ast, expr_ast)) {
|
||||
/* list($a, $b) = $a should evaluate the right $a first */
|
||||
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
|
||||
znode cv_node;
|
||||
|
||||
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
|
||||
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
|
||||
} else {
|
||||
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
|
||||
}
|
||||
} else {
|
||||
zend_compile_expr(&expr_node, expr_ast);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user