Fixed incorrect usage of QM_ASSIGN instruction

This commit is contained in:
Dmitry Stogov 2019-09-13 12:08:59 +03:00
parent 51d9f32dbe
commit e45a757bc2
4 changed files with 21 additions and 13 deletions

3
NEWS
View File

@ -3,6 +3,9 @@ PHP NEWS
?? ??? ????, PHP 7.4.0RC2
- Core:
. Fixed incorrect usage of QM_ASSIGN instruction. It must not return IS_VAR.
As a side effect this allowed passign left hean list() "by reference",
instead of compile-time error. (Dmitry)
. Fixed bug #78531 (Crash when using undefined variable as object). (Dmitry)
- FFI:

View File

@ -20,12 +20,8 @@ var_dump($array);
$array = [1];
$func(list(&$val) = $array);
var_dump($array);
$array = [1];
change(list($val) = $array);
var_dump($array);
?>
--EXPECTF--
--EXPECT--
array(1) {
[0]=>
int(1)
@ -74,9 +70,3 @@ array(10) {
[9]=>
int(10)
}
Notice: Only variables should be passed by reference in %s on line %d
array(1) {
[0]=>
int(1)
}

View File

@ -0,0 +1,15 @@
--TEST--
Bug #73663.2 ("Invalid opcode 65/16/8" occurs with a variable created with list())
--FILE--
<?php
function change(&$ref) {
$ref = range(1, 10);
return;
}
$array = [1];
change(list($val) = $array);
var_dump($array);
?>
--EXPECTF--
Fatal error: Only variables can be passed by reference in %s on line %d

View File

@ -2761,7 +2761,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
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);
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
}
} else {
zend_compile_expr(&expr_node, expr_ast);
@ -2801,7 +2801,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
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);
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
}
} else {
zend_compile_expr(&expr_node, expr_ast);