From: Xinchen Hui Date: Thu, 10 Mar 2016 06:58:10 +0000 (+0800) Subject: Bug #71756 (Call-by-reference widens scope to uninvolved functions when used in switch) X-Git-Tag: php-7.0.5RC1~10^2~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9833c76d3fb6bf4c08aaa4542e87dc33a9b8f6ee;p=php Bug #71756 (Call-by-reference widens scope to uninvolved functions when used in switch) --- diff --git a/NEWS b/NEWS index dad8993e18..0b21ac4b31 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Fixed bug #69953 (Support MKCALENDAR request method). (Christoph) - Core: + . Fixed bug #71756 (Call-by-reference widens scope to uninvolved functions + when used in switch). (Laruence) . Fixed bug #71729 (Possible crash in zend_bin_strtod, zend_oct_strtod, zend_hex_strtod). (Laruence) . Fixed bug #71695 (Global variables are reserved before execution). diff --git a/Zend/tests/bug71756.phpt b/Zend/tests/bug71756.phpt new file mode 100644 index 0000000000..42066f3c2e --- /dev/null +++ b/Zend/tests/bug71756.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #71756 (Call-by-reference widens scope to uninvolved functions when used in switch) +--FILE-- + 'false')); +?> +--EXPECTF-- +array(1) { + ["bla"]=> + string(7) "changed" +} diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 1cf9a2783b..17bc64125a 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1562,6 +1562,9 @@ num_index: break; } } + if (type == BP_VAR_R) { + ZVAL_DEREF(retval); + } } else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) { offset_key = Z_STR_P(dim); if (dim_type != IS_CONST) { @@ -1593,6 +1596,9 @@ str_index: } } } + if (type == BP_VAR_R) { + ZVAL_DEREF(retval); + } } else { switch (type) { case BP_VAR_R: