Skip to content

Commit e45a757

Browse files
committed
Fixed incorrect usage of QM_ASSIGN instruction
1 parent 51d9f32 commit e45a757

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ PHP NEWS
33
?? ??? ????, PHP 7.4.0RC2
44

55
- Core:
6+
. Fixed incorrect usage of QM_ASSIGN instruction. It must not return IS_VAR.
7+
As a side effect this allowed passign left hean list() "by reference",
8+
instead of compile-time error. (Dmitry)
69
. Fixed bug #78531 (Crash when using undefined variable as object). (Dmitry)
710

811
- FFI:

Zend/tests/bug73663.phpt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ var_dump($array);
2020
$array = [1];
2121
$func(list(&$val) = $array);
2222
var_dump($array);
23-
24-
$array = [1];
25-
change(list($val) = $array);
26-
var_dump($array);
2723
?>
28-
--EXPECTF--
24+
--EXPECT--
2925
array(1) {
3026
[0]=>
3127
int(1)
@@ -74,9 +70,3 @@ array(10) {
7470
[9]=>
7571
int(10)
7672
}
77-
78-
Notice: Only variables should be passed by reference in %s on line %d
79-
array(1) {
80-
[0]=>
81-
int(1)
82-
}

Zend/tests/bug73663_2.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #73663.2 ("Invalid opcode 65/16/8" occurs with a variable created with list())
3+
--FILE--
4+
<?php
5+
function change(&$ref) {
6+
$ref = range(1, 10);
7+
return;
8+
}
9+
10+
$array = [1];
11+
change(list($val) = $array);
12+
var_dump($array);
13+
?>
14+
--EXPECTF--
15+
Fatal error: Only variables can be passed by reference in %s on line %d

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,7 +2761,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
27612761
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
27622762
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
27632763
} else {
2764-
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
2764+
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
27652765
}
27662766
} else {
27672767
zend_compile_expr(&expr_node, expr_ast);
@@ -2801,7 +2801,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
28012801
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
28022802
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
28032803
} else {
2804-
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
2804+
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
28052805
}
28062806
} else {
28072807
zend_compile_expr(&expr_node, expr_ast);

0 commit comments

Comments
 (0)