diff options
| author | Nikita Popov <nikic@php.net> | 2014-09-20 21:47:16 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2014-09-20 21:47:59 +0200 |
| commit | 308c0a727ec496ff551f67052b0835de3c152c11 (patch) | |
| tree | db59219113f39cc15b7eef6ca27665c3619dc3eb | |
| parent | 6213d9fc91de457b08e574a0f1ac8073eb948b17 (diff) | |
| parent | 5e977e69e144ca92868ae73cd3563eb473b75937 (diff) | |
| download | php-git-308c0a727ec496ff551f67052b0835de3c152c11.tar.gz | |
Merge branch 'PHP-5.5' into PHP-5.6
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | Zend/tests/bug67633.phpt | 44 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 9 |
3 files changed, 56 insertions, 0 deletions
@@ -2,8 +2,11 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.6.2 +- Core: . Fixed bug #67739 (Windows 8.1/Server 2012 R2 OS build number reported as 6.2 (instead of 6.3)). (Christian Wenz) + . Fixed bug #67633 (A foreach on an array returned from a function not doing + copy-on-write). (Nikita) - FPM: . Fixed bug #65641 (PHP-FPM incorrectly defines the SCRIPT_NAME variable diff --git a/Zend/tests/bug67633.phpt b/Zend/tests/bug67633.phpt new file mode 100644 index 0000000000..a9e05d10ab --- /dev/null +++ b/Zend/tests/bug67633.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #67633: A foreach on an array returned from a function not doing copy-on-write +--FILE-- +<?php + +function id($x) { + return $x; +} + +function &ref_id(&$x) { + return $x; +} + +$c = 'c'; +$array = ['a', 'b', $c]; + +foreach(id($array) as &$v) { + $v .= 'q'; +} +var_dump($array); + +foreach(ref_id($array) as &$v) { + $v .= 'q'; +} +var_dump($array); + +?> +--EXPECT-- +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" +} +array(3) { + [0]=> + string(2) "aq" + [1]=> + string(2) "bq" + [2]=> + &string(2) "cq" +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 54b01a845b..19185dfb70 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6337,6 +6337,15 @@ void zend_do_foreach_begin(znode *foreach_token, znode *open_brackets_token, zno /* save the location of FETCH_W instruction(s) */ open_brackets_token->u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_end_variable_parse(array, BP_VAR_W, 0 TSRMLS_CC); + + if (zend_is_function_or_method_call(array)) { + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_SEPARATE; + SET_NODE(opline->op1, array); + SET_UNUSED(opline->op2); + opline->result_type = IS_VAR; + opline->result.var = opline->op1.var; + } } else { is_variable = 0; open_brackets_token->u.op.opline_num = get_next_op_number(CG(active_op_array)); |
