]> granicus.if.org Git - php/commitdiff
- Fix memleak
authorMarcus Boerger <helly@php.net>
Sat, 3 Feb 2007 14:57:24 +0000 (14:57 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 3 Feb 2007 14:57:24 +0000 (14:57 +0000)
main/main.c
main/php_open_temporary_file.c
main/php_open_temporary_file.h

index 937b2772f909b89293b7157deb6470bce8f69f2f..283bda1e5c44cf3cc982a4e1e1d1443ff6f09f52 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"
@@ -1852,6 +1853,7 @@ void php_module_shutdown(TSRMLS_D)
 #endif
 
        php_output_shutdown();
+       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 */