com php-src: define() must not modify the source array: Zend/tests/constant_arrays.phpt Zend/zend_builtin_fun ctions.c
| From: | Dmitry Stogov | Date: | Thu, 22 Jan 2015 12:49:38 +0000 |
| Subject: | com php-src: define() must not modify the source array: Zend/tests/constant_arrays.phpt Zend/zend_builtin_fun ctions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84316@lists.php.net to get a copy of this message | ||
Commit: faf917d94e6f4f2d56020a422c981a48bd724cf1
Author: Dmitry Stogov <dmitry@zend.com> Thu, 22 Jan 2015 15:49:38 +0300
Parents: 0b70f588221ec41779382928327fcfd3256ca13c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=faf917d94e6f4f2d56020a422c981a48bd724cf1
Log:
define() must not modify the source array
Changed paths:
M Zend/tests/constant_arrays.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/Zend/tests/constant_arrays.phpt b/Zend/tests/constant_arrays.phpt
index 834c126..5bb8717 100644
--- a/Zend/tests/constant_arrays.phpt
+++ b/Zend/tests/constant_arrays..phpt
@@ -85,7 +85,7 @@ array(4) {
int(3)
array(1) {
[0]=>
- int(3)
+ &int(3)
}
array(1) {
[0]=>
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 6b73bf3...f5dd831 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -746,14 +746,7 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */
array_init_size(dst, zend_hash_num_elements(Z_ARRVAL_P(src)));
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(src), idx, key, val) {
/* constant arrays can't contain references */
- if (Z_ISREF_P(val)) {
- if (Z_REFCOUNT_P(val) == 1) {
- ZVAL_UNREF(val);
- } else {
- Z_DELREF_P(val);
- val = Z_REFVAL_P(val);
- }
- }
+ ZVAL_DEREF(val);
if (key) {
new_val = zend_hash_add_new(Z_ARRVAL_P(dst), key, val);
} else {