From: Dmitry Stogov Date: Mon, 17 Jul 2006 07:20:12 +0000 (+0000) Subject: Fixed memory leaks in ZTS mode. X-Git-Tag: php-5.2.0RC1~85 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d68797945af1939b328687642cfaa705565d8ca4;p=php Fixed memory leaks in ZTS mode. --- diff --git a/main/main.c b/main/main.c index e2e8e37610..4648f5ad6e 100644 --- a/main/main.c +++ b/main/main.c @@ -1350,6 +1350,25 @@ static void core_globals_ctor(php_core_globals *core_globals TSRMLS_DC) /* }}} */ #endif +/* {{{ core_globals_dtor + */ +static void core_globals_dtor(php_core_globals *core_globals TSRMLS_DC) +{ + if (core_globals->last_error_message) { + free(core_globals->last_error_message); + } + if (core_globals->last_error_file) { + free(core_globals->last_error_file); + } + if (core_globals->disable_functions) { + free(core_globals->disable_functions); + } + if (core_globals->disable_classes) { + free(core_globals->disable_classes); + } +} +/* }}} */ + /* {{{ php_register_extensions */ int php_register_extensions(zend_module_entry **ptr, int count TSRMLS_DC) @@ -1436,7 +1455,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod #ifdef ZTS executor_globals = ts_resource(executor_globals_id); - ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, NULL); + ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); core_globals = ts_resource(core_globals_id); #ifdef PHP_WIN32 ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, NULL); @@ -1639,23 +1658,13 @@ void php_module_shutdown(TSRMLS_D) #ifndef ZTS zend_ini_shutdown(TSRMLS_C); shutdown_memory_manager(CG(unclean_shutdown), 1 TSRMLS_CC); + core_globals_dtor(&core_globals TSRMLS_CC); #else zend_ini_global_shutdown(TSRMLS_C); + ts_free_id(core_globals_id); #endif module_initialized = 0; - if (PG(last_error_message)) { - free(PG(last_error_message)); - } - if (PG(last_error_file)) { - free(PG(last_error_file)); - } - if (PG(disable_functions)) { - free(PG(disable_functions)); - } - if (PG(disable_classes)) { - free(PG(disable_classes)); - } } /* }}} */