diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-02-16 11:02:57 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-02-16 11:02:57 +0800 |
commit | 0fccd154bdb27476289bab18a9112fb7b20ae607 (patch) | |
tree | 2db66403a790907202112a942df59ea4df58f9c8 | |
parent | 23b770f31fdf893239a185bdb36876c5438eb813 (diff) | |
download | php-git-0fccd154bdb27476289bab18a9112fb7b20ae607.tar.gz |
Fixed bug #71603 (compact() maintains references in php7)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/standard/array.c | 1 | ||||
-rw-r--r-- | ext/standard/tests/array/bug71603.phpt | 15 |
3 files changed, 17 insertions, 0 deletions
@@ -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 cd058ae68a..5add302c46 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 0000000000..0c25be660c --- /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" |