summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-10-30 23:13:10 +0300
committerDmitry Stogov <dmitry@zend.com>2017-10-30 23:13:10 +0300
commitfcc08ce19f39f7ab1381ecc8a010037d41819329 (patch)
treec390b9b848758ad8e8b79b8f11e9a798a7de039d /Zend/zend_builtin_functions.c
parentdc4427d0caf2d066cd01f91fd0e899217fbceb30 (diff)
downloadphp-git-fcc08ce19f39f7ab1381ecc8a010037d41819329.tar.gz
Prevent reference-counting on persistent zvals (internal constants, default properties and constants of internal classes).
New macro ZVAL_COPY_OR_DUP() is used perform duplication, if necessary. This should eliminate related race-coditions in ZTS build and prevent reference-counting bugs after unclean shutdown.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 0d6cc442b6..37bf4f82e0 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1064,12 +1064,8 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, int st
/* copy: enforce read only access */
ZVAL_DEREF(prop);
- if (UNEXPECTED(Z_COPYABLE_P(prop))) {
- ZVAL_DUP(&prop_copy, prop);
- prop = &prop_copy;
- } else {
- Z_TRY_ADDREF_P(prop);
- }
+ ZVAL_COPY_OR_DUP(&prop_copy, prop);
+ prop = &prop_copy;
/* this is necessary to make it able to work with default array
* properties, returned to user */
@@ -2032,7 +2028,7 @@ static int add_constant_info(zval *item, void *arg) /* {{{ */
return 0;
}
- ZVAL_DUP(&const_val, &constant->value);
+ ZVAL_COPY_OR_DUP(&const_val, &constant->value);
zend_hash_add_new(Z_ARRVAL_P(name_array), constant->name, &const_val);
return 0;
}
@@ -2108,7 +2104,7 @@ ZEND_FUNCTION(get_defined_constants)
add_assoc_zval(return_value, module_names[module_number], &modules[module_number]);
}
- ZVAL_DUP(&const_val, &val->value);
+ ZVAL_COPY_OR_DUP(&const_val, &val->value);
zend_hash_add_new(Z_ARRVAL(modules[module_number]), val->name, &const_val);
} ZEND_HASH_FOREACH_END();