Merge branch 'PHP-7.0'

* PHP-7.0:
  Fixed bug #71914 (Reference is lost in "switch")
This commit is contained in:
Xinchen Hui 2016-03-29 17:14:48 +08:00
commit 0a2746fb4b
3 changed files with 35 additions and 10 deletions

25
Zend/tests/bug71914.phpt Normal file
View File

@ -0,0 +1,25 @@
--TEST--
Bug #71914 (Reference is lost in "switch")
--FILE--
<?php
function bug(&$value) {
switch ($value) {
case "xxxx":
$value = true;
break;
}
}
function test($arr, &$dummy) {
bug($arr["str"]);
var_dump($arr["str"]);
}
$array = array("str" => "xxxx");
test($array, $array["str"]);
?>
--EXPECT--
bool(true)

View File

@ -5054,7 +5054,7 @@ ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
SAVE_OPLINE();
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((OP1_TYPE & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((OP1_TYPE & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);

View File

@ -6294,7 +6294,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CONST_CONST_HANDLER(
SAVE_OPLINE();
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CONST & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CONST & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -10152,7 +10152,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CONST_CV_HANDLER(ZEN
SAVE_OPLINE();
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CONST & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CONST & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -12010,7 +12010,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CONST_TMPVAR_HANDLER
SAVE_OPLINE();
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CONST & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CONST & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -39602,7 +39602,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CV_CONST_HANDLER(ZEN
SAVE_OPLINE();
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CV & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CV & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -46090,7 +46090,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CV_CV_HANDLER(ZEND_O
SAVE_OPLINE();
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CV & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CV & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -49631,7 +49631,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_CV_TMPVAR_HANDLER(ZE
SAVE_OPLINE();
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if ((IS_CV & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if ((IS_CV & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -51855,7 +51855,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CONST_HANDLER
SAVE_OPLINE();
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if (((IS_TMP_VAR|IS_VAR) & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -54195,7 +54195,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CV_HANDLER(ZE
SAVE_OPLINE();
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if (((IS_TMP_VAR|IS_VAR) & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);
@ -55440,7 +55440,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_TMPVAR_HANDLE
SAVE_OPLINE();
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && UNEXPECTED(Z_ISREF_P(op1))) {
} else if (((IS_TMP_VAR|IS_VAR) & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
/* Don't keep lock on reference, lock the value instead */
if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
ZVAL_UNREF(op1);