mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
- Fix leaks with registered shutdown functions.
This commit is contained in:
@@ -2282,14 +2282,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;
|
||||
|
||||
@@ -1131,11 +1131,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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user