Skip to content

Commit cf754a9

Browse files
committed
adds zend_type_release_internal()
1 parent 90ca716 commit cf754a9

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
34963496
ZEND_HASH_MAP_FOREACH_PTR(&disabled_class->properties_info, prop) {
34973497
if (prop->ce == disabled_class) {
34983498
zend_string_release(prop->name);
3499-
zend_type_release(prop->type, /* persistent */ 1);
3499+
zend_type_release_internal(prop->type);
35003500
free(prop);
35013501
}
35023502
} ZEND_HASH_FOREACH_END();

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle);
863863
ZEND_API void zend_cleanup_mutable_class_data(zend_class_entry *ce);
864864
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce);
865865
ZEND_API void zend_type_release(zend_type type, bool persistent);
866+
ZEND_API void zend_type_release_internal(zend_type type);
866867
ZEND_API zend_string *zend_create_member_string(zend_string *class_name, zend_string *member_name);
867868

868869

Zend/zend_opcode.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ ZEND_API void zend_type_release(zend_type type, bool persistent) {
118118
zend_string_release(ZEND_TYPE_NAME(*sublist_type));
119119
}
120120
} ZEND_TYPE_LIST_FOREACH_END();
121-
if (!ZEND_TYPE_USES_ARENA(*list_type) && persistent) {
122-
free(ZEND_TYPE_LIST(*list_type));
123-
}
121+
// if (!ZEND_TYPE_USES_ARENA(*list_type) && persistent) {
122+
// free(ZEND_TYPE_LIST(*list_type));
123+
// }
124124
} else if (ZEND_TYPE_HAS_NAME(*list_type)) {
125125
zend_string_release(ZEND_TYPE_NAME(*list_type));
126126
}
@@ -133,6 +133,28 @@ ZEND_API void zend_type_release(zend_type type, bool persistent) {
133133
}
134134
}
135135

136+
ZEND_API void zend_type_release_internal(zend_type type) {
137+
ZEND_ASSERT(!ZEND_TYPE_USES_ARENA(type));
138+
if (ZEND_TYPE_HAS_LIST(type)) {
139+
zend_type *list_type, *sublist_type;
140+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(type), list_type) {
141+
if (ZEND_TYPE_HAS_LIST(*list_type)) {
142+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*list_type), sublist_type) {
143+
if (ZEND_TYPE_HAS_NAME(*sublist_type)) {
144+
zend_string_release(ZEND_TYPE_NAME(*sublist_type));
145+
}
146+
} ZEND_TYPE_LIST_FOREACH_END();
147+
free(ZEND_TYPE_LIST(*list_type));
148+
} else if (ZEND_TYPE_HAS_NAME(*list_type)) {
149+
zend_string_release(ZEND_TYPE_NAME(*list_type));
150+
}
151+
} ZEND_TYPE_LIST_FOREACH_END();
152+
free(ZEND_TYPE_LIST(type));
153+
} else if (ZEND_TYPE_HAS_NAME(type)) {
154+
zend_string_release(ZEND_TYPE_NAME(type));
155+
}
156+
}
157+
136158
void zend_free_internal_arg_info(zend_internal_function *function) {
137159
if ((function->fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS)) &&
138160
function->arg_info) {
@@ -145,7 +167,7 @@ void zend_free_internal_arg_info(zend_internal_function *function) {
145167
num_args++;
146168
}
147169
for (i = 0 ; i < num_args; i++) {
148-
zend_type_release(arg_info[i].type, /* persistent */ 1);
170+
zend_type_release_internal(arg_info[i].type);
149171
}
150172
free(arg_info);
151173
}
@@ -457,7 +479,7 @@ ZEND_API void destroy_zend_class(zval *zv)
457479
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop_info) {
458480
if (prop_info->ce == ce) {
459481
zend_string_release(prop_info->name);
460-
zend_type_release(prop_info->type, /* persistent */ 1);
482+
zend_type_release_internal(prop_info->type);
461483
free(prop_info);
462484
}
463485
} ZEND_HASH_FOREACH_END();
@@ -492,6 +514,7 @@ ZEND_API void destroy_zend_class(zval *zv)
492514
} else {
493515
zval_internal_ptr_dtor(&c->value);
494516
}
517+
zend_type_release_internal(c->type);
495518
if (c->doc_comment) {
496519
zend_string_release_ex(c->doc_comment, 1);
497520
}

0 commit comments

Comments
 (0)