Skip to content

Commit 805637b

Browse files
committed
Fix mem leak
1 parent 6716188 commit 805637b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,7 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
22172217
zend_property_info property_info;
22182218
zend_property_info *existing_property_info;
22192219
HashTable *target_symbol_table;
2220+
zend_bool free_var_name = 0;
22202221

22212222
if (access_type & ZEND_ACC_ABSTRACT) {
22222223
zend_error(E_COMPILE_ERROR, "Properties cannot be declared abstract");
@@ -2252,6 +2253,7 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
22522253
int priv_name_length;
22532254

22542255
mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len);
2256+
free_var_name = 1;
22552257
zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);
22562258
property_info.name = priv_name;
22572259
property_info.name_length = priv_name_length;
@@ -2262,6 +2264,7 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
22622264
int prot_name_length;
22632265

22642266
mangle_property_name(&prot_name, &prot_name_length, "*", 1, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len);
2267+
free_var_name = 1;
22652268
zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
22662269
property_info.name = prot_name;
22672270
property_info.name_length = prot_name_length;
@@ -2277,6 +2280,9 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
22772280
property_info.h = zend_get_hash_value(property_info.name, property_info.name_length+1);
22782281

22792282
zend_hash_update(&CG(active_class_entry)->properties_info, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property_info, sizeof(zend_property_info), NULL);
2283+
if (free_var_name) {
2284+
efree(var_name->u.constant.value.str.val);
2285+
}
22802286
}
22812287

22822288

0 commit comments

Comments
 (0)