summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-11-25 13:31:18 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-11-25 17:12:37 +0100
commit8795893f4f90a344cc9a9d48523b7aa0ba5ebf05 (patch)
treeeac7bf2dd53d1fff18b8433e6f2b570066df64ac /Zend/zend_API.c
parentc5767db441e4db2a1e07b5880129ad7ce0b25b6f (diff)
downloadphp-git-8795893f4f90a344cc9a9d48523b7aa0ba5ebf05.tar.gz
Make sure string property/class const values are interned
This was done for user-definde class constant values, however this is also important for properties and internal classes.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 03a0df947e..53eca994a6 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3616,6 +3616,16 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
}
/* }}} */
+static inline zend_string *zval_make_interned_string(zval *zv) /* {{{ */
+{
+ ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING);
+ Z_STR_P(zv) = zend_new_interned_string(Z_STR_P(zv));
+ if (ZSTR_IS_INTERNED(Z_STR_P(zv))) {
+ Z_TYPE_FLAGS_P(zv) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
+ }
+ return Z_STR_P(zv);
+}
+
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */
{
zend_property_info *property_info, *property_info_ptr;
@@ -3632,6 +3642,10 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
}
}
+ if (Z_TYPE_P(property) == IS_STRING && !ZSTR_IS_INTERNED(Z_STR_P(property))) {
+ zval_make_interned_string(property);
+ }
+
if (!(access_type & ZEND_ACC_PPP_MASK)) {
access_type |= ZEND_ACC_PUBLIC;
}
@@ -3774,6 +3788,10 @@ ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *n
"A class constant must not be called 'class'; it is reserved for class name fetching");
}
+ if (Z_TYPE_P(value) == IS_STRING && !ZSTR_IS_INTERNED(Z_STR_P(value))) {
+ zval_make_interned_string(value);
+ }
+
if (ce->type == ZEND_INTERNAL_CLASS) {
c = pemalloc(sizeof(zend_class_constant), 1);
} else {