com php-src: Fix bug #71529: NEWS Zend/tests/bug71529.phpt Zend/zend_compile.c

From: Date: Sat, 06 Feb 2016 15:43:28 +0000
Subject: com php-src: Fix bug #71529: NEWS Zend/tests/bug71529.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90961@lists.php.net to get a copy of this message
Commit: 9f82f21d018aafbfea723960a335f435202bff77 Author: Nikita Popov <nikic@php.net> Sat, 6 Feb 2016 16:38:59 +0100 Parents: d6457065476dcb40fb73f2151805649b4bab392b Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9f82f21d018aafbfea723960a335f435202bff77 Log: Fix bug #71529 Bugs: https://bugs.php.net/71529 Changed paths: M NEWS A Zend/tests/bug71529.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index a69e070..5ea1dff 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ PHP NEWS . Fixed bug #71442 (forward_static_call crash). (Laruence) . Fixed bug #71441 (Typehinted Generator with return in try/finally crashes). (Bob) + . Fixed bug #71529 (Variable references on array elements don't work when + using count). (Nikita) - CURL: . Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes diff --git a/Zend/tests/bug71529.phpt b/Zend/tests/bug71529.phpt new file mode 100644 index 0000000..5a5e323 --- /dev/null +++ b/Zend/tests/bug71529.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #71529: Variable references on array elements don't work when using count +--FILE-- +<?php + +$a = [1]; +$a[] = &$a[out(count($a) - 1)]; +var_dump($a); + +function out($what) { + var_dump($what); + return $what; +} + +?> +--EXPECT-- +int(0) +array(2) { + [0]=> + &int(1) + [1]=> + &int(1) +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 1c30b98..58be2ed 100644 --- a/Zend/zend_compile..c +++ b/Zend/zend_compile.c @@ -2589,14 +2589,17 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */ znode target_node, source_node; zend_op *opline; + uint32_t offset; if (is_this_fetch(target_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this"); } zend_ensure_writable_variable(target_ast); - zend_compile_var(&target_node, target_ast, BP_VAR_W); - zend_compile_var(&source_node, source_ast, BP_VAR_REF); + offset = zend_delayed_compile_begin(); + zend_delayed_compile_var(&target_node, target_ast, BP_VAR_W); + zend_delayed_compile_var(&source_node, source_ast, BP_VAR_REF); + zend_delayed_compile_end(offset); if (source_node.op_type != IS_VAR && zend_is_call(source_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use result of built-in function in write context");

« previous php.cvs (#90961) next »