Permalink
Browse files

- Fix leaks with registered shutdown functions.

  • Loading branch information...
1 parent 2da8b01 commit 6ffb0dcaf2f3dc1194522afe0c5af226bd757e31 foobar committed Jan 9, 2005
Showing with 16 additions and 6 deletions.
  1. +10 −3 ext/standard/basic_functions.c
  2. +4 −2 main/main.c
  3. +2 −1 main/php_main.h
@@ -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;
View
@@ -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 {
View
@@ -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);

0 comments on commit 6ffb0dc

Please sign in to comment.