From: Marcus Boerger Date: Wed, 7 Feb 2007 21:01:06 +0000 (+0000) Subject: - MFH Fix memleak with temp dir X-Git-Tag: php-5.2.2RC1~450 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ded8042b9c02d4f113866b76df3a8569d31a10a;p=php - MFH Fix memleak with temp dir --- diff --git a/main/main.c b/main/main.c index 9e6794b718..abb27b8695 100644 --- a/main/main.c +++ b/main/main.c @@ -83,6 +83,7 @@ #include "php_ticks.h" #include "php_logos.h" #include "php_streams.h" +#include "php_open_temporary_file.h" #include "SAPI.h" #include "rfc1867.h" @@ -1692,6 +1693,8 @@ void php_module_shutdown(TSRMLS_D) ts_free_id(core_globals_id); #endif + php_shutdown_temporary_directory(); + module_initialized = 0; } /* }}} */ diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 5b673619c8..c59d8e6407 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -148,14 +148,22 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** } /* }}} */ +/* Cache the chosen temporary directory. */ +static char* temporary_directory; + +PHPAPI void php_shutdown_temporary_directory() +{ + if (temporary_directory) { + free(temporary_directory); + temporary_directory = NULL; + } +} + /* * Determine where to place temporary files. */ PHPAPI const char* php_get_temporary_directory(void) { - /* Cache the chosen temporary directory. */ - static char* temporary_directory; - /* Did we determine the temporary directory already? */ if (temporary_directory) { return temporary_directory; diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h index 43b36def7e..9565fcd6ca 100644 --- a/main/php_open_temporary_file.h +++ b/main/php_open_temporary_file.h @@ -25,6 +25,7 @@ BEGIN_EXTERN_C() PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC); PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC); PHPAPI const char *php_get_temporary_directory(void); +PHPAPI void php_shutdown_temporary_directory(); END_EXTERN_C() #endif /* PHP_OPEN_TEMPORARY_FILE_H */