Skip to content

Commit 6e7a301

Browse files
committed
fix bug #54423 (classes from dl()'ed extensions are not destroyed)
1 parent 27c0221 commit 6e7a301

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Zend/zend_API.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,13 +2208,30 @@ ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */
22082208
}
22092209
/* }}} */
22102210

2211+
static int clean_module_class(const zend_class_entry **ce, int *module_number TSRMLS_DC) /* {{{ */
2212+
{
2213+
if ((*ce)->type == ZEND_INTERNAL_CLASS && (*ce)->module->module_number == *module_number) {
2214+
return ZEND_HASH_APPLY_REMOVE;
2215+
} else {
2216+
return ZEND_HASH_APPLY_KEEP;
2217+
}
2218+
}
2219+
/* }}} */
2220+
2221+
static void clean_module_classes(int module_number TSRMLS_DC) /* {{{ */
2222+
{
2223+
zend_hash_apply_with_argument(EG(class_table), (apply_func_arg_t) clean_module_class, (void *) &module_number TSRMLS_CC);
2224+
}
2225+
/* }}} */
2226+
22112227
void module_destructor(zend_module_entry *module) /* {{{ */
22122228
{
22132229
TSRMLS_FETCH();
22142230

22152231
if (module->type == MODULE_TEMPORARY) {
22162232
zend_clean_module_rsrc_dtors(module->module_number TSRMLS_CC);
22172233
clean_module_constants(module->module_number TSRMLS_CC);
2234+
clean_module_classes(module->module_number TSRMLS_CC);
22182235
}
22192236

22202237
if (module->module_started && module->module_shutdown_func) {

0 commit comments

Comments
 (0)