Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,8 @@ void zend_shutdown(void) /* {{{ */
virtual_cwd_shutdown();

zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
zend_hash_destroy(GLOBAL_CLASS_TABLE);
/* Child classes may reuse structures from parent classes, so destroy in reverse order. */
zend_hash_graceful_reverse_destroy(GLOBAL_CLASS_TABLE);

zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
free(GLOBAL_AUTO_GLOBALS_TABLE);
Expand Down
8 changes: 8 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,7 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
zend_class_entry *disabled_class;
zend_string *key;
zend_function *fn;
zend_property_info *prop;

key = zend_string_alloc(class_name_length, 0);
zend_str_tolower_copy(ZSTR_VAL(key), class_name, class_name_length);
Expand All @@ -3253,6 +3254,13 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
}
} ZEND_HASH_FOREACH_END();
zend_hash_clean(&disabled_class->function_table);
ZEND_HASH_FOREACH_PTR(&disabled_class->properties_info, prop) {
if (prop->ce == disabled_class) {
zend_string_release(prop->name);
zend_type_release(prop->type, /* persistent */ 1);
free(prop);
}
} ZEND_HASH_FOREACH_END();
zend_hash_clean(&disabled_class->properties_info);
return SUCCESS;
}
Expand Down
12 changes: 1 addition & 11 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ static zend_brk_cont_element *get_next_brk_cont_element(void)
return &CG(context).brk_cont_array[CG(context).last_brk_cont-1];
}

static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
{
zend_property_info *property_info = Z_PTR_P(zv);

zend_string_release(property_info->name);
zend_type_release(property_info->type, /* persistent */ 1);
free(property_info);
}
/* }}} */

static zend_string *zend_build_runtime_definition_key(zend_string *name, uint32_t start_lineno) /* {{{ */
{
zend_string *filename = CG(active_op_array)->filename;
Expand Down Expand Up @@ -1867,7 +1857,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_hand

ce->default_properties_table = NULL;
ce->default_static_members_table = NULL;
zend_hash_init(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes);
zend_hash_init(&ce->properties_info, 8, NULL, NULL, persistent_hashes);
zend_hash_init(&ce->constants_table, 8, NULL, NULL, persistent_hashes);
zend_hash_init(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes);

Expand Down
18 changes: 1 addition & 17 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ static void zend_type_copy_ctor(zend_type *type, bool persistent) {
}
}

static zend_property_info *zend_duplicate_property_info_internal(zend_property_info *property_info) /* {{{ */
{
zend_property_info* new_property_info = pemalloc(sizeof(zend_property_info), 1);
memcpy(new_property_info, property_info, sizeof(zend_property_info));
zend_string_addref(new_property_info->name);
zend_type_copy_ctor(&new_property_info->type, /* persistent */ 1);

return new_property_info;
}
/* }}} */

static zend_function *zend_duplicate_internal_function(zend_function *func, zend_class_entry *ce) /* {{{ */
{
zend_function *new_function;
Expand Down Expand Up @@ -1100,12 +1089,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
}
}
} else {
if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
child_info = zend_duplicate_property_info_internal(parent_info);
} else {
child_info = parent_info;
}
_zend_hash_append_ptr(&ce->properties_info, key, child_info);
_zend_hash_append_ptr(&ce->properties_info, key, parent_info);
}
}
/* }}} */
Expand Down
8 changes: 8 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ ZEND_API void destroy_zend_class(zval *zv)
zend_cleanup_internal_class_data(ce);
}
}

ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
if (prop_info->ce == ce) {
zend_string_release(prop_info->name);
zend_type_release(prop_info->type, /* persistent */ 1);
free(prop_info);
}
} ZEND_HASH_FOREACH_END();
zend_hash_destroy(&ce->properties_info);
zend_string_release_ex(ce->name, 1);

Expand Down