From: foobar Date: Sun, 9 Jan 2005 16:30:15 +0000 (+0000) Subject: MFH: - Fix leaks with registered shutdown functions. X-Git-Tag: php-5.0.4RC1~376 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4108b718984f499a53b294ee5d4270966d8ed09;p=php MFH: - Fix leaks with registered shutdown functions. --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index bca5328ac6..68cbbe96a1 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2188,14 +2188,21 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_ } } -void php_call_shutdown_functions(void) +void php_call_shutdown_functions(TSRMLS_D) { - TSRMLS_FETCH(); - if (BG(user_shutdown_function_names)) zend_try { zend_hash_apply(BG(user_shutdown_function_names), (apply_func_t) user_shutdown_function_call TSRMLS_CC); memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf)); + php_free_shutdown_functions(TSRMLS_C); + } + zend_end_try(); +} + +void php_free_shutdown_functions(TSRMLS_D) +{ + if (BG(user_shutdown_function_names)) + zend_try { zend_hash_destroy(BG(user_shutdown_function_names)); FREE_HASHTABLE(BG(user_shutdown_function_names)); BG(user_shutdown_function_names) = NULL; diff --git a/main/main.c b/main/main.c index 125295bf24..5b13943a5d 100644 --- a/main/main.c +++ b/main/main.c @@ -1135,11 +1135,12 @@ void php_request_shutdown_for_hook(void *dummy) { TSRMLS_FETCH(); if (PG(modules_activated)) zend_try { - php_call_shutdown_functions(); + php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); + php_free_shutdown_functions(TSRMLS_C); } zend_try { @@ -1191,11 +1192,12 @@ void php_request_shutdown(void *dummy) } zend_end_try(); if (PG(modules_activated)) zend_try { - php_call_shutdown_functions(); + php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); + php_free_shutdown_functions(TSRMLS_C); } zend_try { diff --git a/main/php_main.h b/main/php_main.h index 01656e5d24..883953643f 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -48,7 +48,8 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC); PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC); -extern void php_call_shutdown_functions(void); +extern void php_call_shutdown_functions(TSRMLS_D); +extern void php_free_shutdown_functions(TSRMLS_D); /* environment module */ extern int php_init_environ(void);