From: Marcus Boerger Date: Sat, 3 Feb 2007 14:57:24 +0000 (+0000) Subject: - Fix memleak X-Git-Tag: RELEASE_1_0_0RC1~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66398d4e3e17753424dc38741c0b46465a138a4d;p=php - Fix memleak --- diff --git a/main/main.c b/main/main.c index 937b2772f9..283bda1e5c 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" @@ -1852,6 +1853,7 @@ void php_module_shutdown(TSRMLS_D) #endif php_output_shutdown(); + 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 */