@@ -1893,10 +1893,10 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
1893
1893
}
1894
1894
}
1895
1895
fname_len = strlen (ptr -> fname );
1896
- lowercase_name = zend_str_tolower_dup (ptr -> fname , fname_len );
1896
+ lowercase_name = CG ( new_interned_string )( zend_str_tolower_dup (ptr -> fname , fname_len ), fname_len + 1 , 1 TSRMLS_CC );
1897
1897
if (zend_hash_add (target_function_table , lowercase_name , fname_len + 1 , & function , sizeof (zend_function ), (void * * )& reg_function ) == FAILURE ) {
1898
1898
unload = 1 ;
1899
- efree (lowercase_name );
1899
+ str_efree (lowercase_name );
1900
1900
break ;
1901
1901
}
1902
1902
if (scope ) {
@@ -1938,7 +1938,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
1938
1938
}
1939
1939
ptr ++ ;
1940
1940
count ++ ;
1941
- efree (lowercase_name );
1941
+ str_efree (lowercase_name );
1942
1942
}
1943
1943
if (unload ) { /* before unloading, display all remaining bad function in the module */
1944
1944
if (scope ) {
@@ -2168,7 +2168,7 @@ int zend_next_free_module(void) /* {{{ */
2168
2168
static zend_class_entry * do_register_internal_class (zend_class_entry * orig_class_entry , zend_uint ce_flags TSRMLS_DC ) /* {{{ */
2169
2169
{
2170
2170
zend_class_entry * class_entry = malloc (sizeof (zend_class_entry ));
2171
- char * lowercase_name = malloc (orig_class_entry -> name_length + 1 );
2171
+ char * lowercase_name = emalloc (orig_class_entry -> name_length + 1 );
2172
2172
* class_entry = * orig_class_entry ;
2173
2173
2174
2174
class_entry -> type = ZEND_INTERNAL_CLASS ;
@@ -2181,8 +2181,9 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class
2181
2181
}
2182
2182
2183
2183
zend_str_tolower_copy (lowercase_name , orig_class_entry -> name , class_entry -> name_length );
2184
+ lowercase_name = CG (new_interned_string )(lowercase_name , class_entry -> name_length + 1 , 1 TSRMLS_CC );
2184
2185
zend_hash_update (CG (class_table ), lowercase_name , class_entry -> name_length + 1 , & class_entry , sizeof (zend_class_entry * ), NULL );
2185
- free (lowercase_name );
2186
+ str_efree (lowercase_name );
2186
2187
return class_entry ;
2187
2188
}
2188
2189
/* }}} */
@@ -3070,6 +3071,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
3070
3071
{
3071
3072
zend_property_info property_info ;
3072
3073
HashTable * target_symbol_table ;
3074
+ char * interned_name ;
3073
3075
3074
3076
if (!(access_type & ZEND_ACC_PPP_MASK )) {
3075
3077
access_type |= ZEND_ACC_PUBLIC ;
@@ -3097,7 +3099,6 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
3097
3099
int priv_name_length ;
3098
3100
3099
3101
zend_mangle_property_name (& priv_name , & priv_name_length , ce -> name , ce -> name_length , name , name_length , ce -> type & ZEND_INTERNAL_CLASS );
3100
- zend_hash_update (target_symbol_table , priv_name , priv_name_length + 1 , & property , sizeof (zval * ), NULL );
3101
3102
property_info .name = priv_name ;
3102
3103
property_info .name_length = priv_name_length ;
3103
3104
}
@@ -3107,7 +3108,6 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
3107
3108
int prot_name_length ;
3108
3109
3109
3110
zend_mangle_property_name (& prot_name , & prot_name_length , "*" , 1 , name , name_length , ce -> type & ZEND_INTERNAL_CLASS );
3110
- zend_hash_update (target_symbol_table , prot_name , prot_name_length + 1 , & property , sizeof (zval * ), NULL );
3111
3111
property_info .name = prot_name ;
3112
3112
property_info .name_length = prot_name_length ;
3113
3113
}
@@ -3121,11 +3121,27 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
3121
3121
zend_hash_del (target_symbol_table , prot_name , prot_name_length + 1 );
3122
3122
pefree (prot_name , ce -> type & ZEND_INTERNAL_CLASS );
3123
3123
}
3124
- zend_hash_update (target_symbol_table , name , name_length + 1 , & property , sizeof (zval * ), NULL );
3125
- property_info .name = ce -> type & ZEND_INTERNAL_CLASS ? zend_strndup (name , name_length ) : estrndup (name , name_length );
3124
+ if (IS_INTERNED (name )) {
3125
+ property_info .name = (char * )name ;
3126
+ } else {
3127
+ property_info .name = ce -> type & ZEND_INTERNAL_CLASS ? zend_strndup (name , name_length ) : estrndup (name , name_length );
3128
+ }
3126
3129
property_info .name_length = name_length ;
3127
3130
break ;
3128
3131
}
3132
+
3133
+ interned_name = CG (new_interned_string )(property_info .name , property_info .name_length + 1 , 0 TSRMLS_CC );
3134
+ if (interned_name != property_info .name ) {
3135
+ if (ce -> type == ZEND_USER_CLASS ) {
3136
+ efree (property_info .name );
3137
+ } else {
3138
+ free (property_info .name );
3139
+ }
3140
+ property_info .name = interned_name ;
3141
+ }
3142
+
3143
+ zend_hash_update (target_symbol_table , property_info .name , property_info .name_length + 1 , & property , sizeof (zval * ), NULL );
3144
+
3129
3145
property_info .flags = access_type ;
3130
3146
property_info .h = zend_get_hash_value (property_info .name , property_info .name_length + 1 );
3131
3147
0 commit comments