]> granicus.if.org Git - php/commitdiff
- MFH Fix memleak with temp dir
authorMarcus Boerger <helly@php.net>
Wed, 7 Feb 2007 21:01:06 +0000 (21:01 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 7 Feb 2007 21:01:06 +0000 (21:01 +0000)
main/main.c
main/php_open_temporary_file.c
main/php_open_temporary_file.h

index 9e6794b71843bb0b28c046a7db215aeab7c6f803..abb27b86955ca6a7e9fea4a9e6aa32ebae61b244 100644 (file)
@@ -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;
 }
 /* }}} */
index 5b673619c88c85e56256be835986f3b38e4480cb..c59d8e6407777888fc623c4a3699f2a8e8b41bdc 100644 (file)
@@ -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;
index 43b36def7efd2feffc8877b58f41271a5a125e17..9565fcd6ca3d382d56177589b03ee52842705bae 100644 (file)
@@ -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 */