com php-src: Fixed bug #71603 (compact() maintains references in php7): NEWS ext/standard/array.c ext/standard/tests/array/bug71603.phpt

From: Date: Tue, 16 Feb 2016 03:02:57 +0000
Subject: com php-src: Fixed bug #71603 (compact() maintains references in php7): NEWS ext/standard/array.c ext/standard/tests/array/bug71603.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91062@lists.php.net to get a copy of this message
Commit: 0fccd154bdb27476289bab18a9112fb7b20ae607 Author: Xinchen Hui <laruence@gmail.com> Tue, 16 Feb 2016 11:02:57 +0800 Parents: 23b770f31fdf893239a185bdb36876c5438eb813 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0fccd154bdb27476289bab18a9112fb7b20ae607 Log: Fixed bug #71603 (compact() maintains references in php7) Bugs: https://bugs.php.net/71603 Changed paths: M NEWS M ext/standard/array.c A ext/standard/tests/array/bug71603.phpt Diff: diff --git a/NEWS b/NEWS index 15667a6..eae72f0 100644 --- a/NEWS +++ b/NEWS @@ -54,6 +54,7 @@ PHP NEWS phpdbg_get_executable(). (Bob) - Standard: + . Fixed bug #71603 (compact() maintains references in php7). (Laruence) . Fixed bug #70720 (strip_tags improper php code parsing). (Julien) - XMLRPC: diff --git a/ext/standard/array.c b/ext/standard/array.c index cd058ae..5add302 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1944,6 +1944,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu ZVAL_DEREF(entry); if (Z_TYPE_P(entry) == IS_STRING) { if ((value_ptr = zend_hash_find_ind(eg_active_symbol_table, Z_STR_P(entry))) != NULL) { + ZVAL_DEREF(value_ptr); ZVAL_COPY(&data, value_ptr); zend_hash_update(Z_ARRVAL_P(return_value), Z_STR_P(entry), &data); } diff --git a/ext/standard/tests/array/bug71603.phpt b/ext/standard/tests/array/bug71603.phpt new file mode 100644 index 0000000..0c25be6 --- /dev/null +++ b/ext/standard/tests/array/bug71603.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #71603 (compact() maintains references in php7) +--FILE-- +<?php +$foo = "okey"; +$foo_reference =& $foo; + +$array = compact('foo_reference'); + +$foo = 'changed!'; + +var_dump($array['foo_reference']); + +--EXPECT-- +string(4) "okey"

« previous php.cvs (#91062) next »