]> granicus.if.org Git - php/commitdiff
Fix for #66048
authorJulien Pauli <jpauli@php.net>
Tue, 12 May 2015 14:12:29 +0000 (16:12 +0200)
committerJulien Pauli <jpauli@php.net>
Tue, 12 May 2015 14:12:29 +0000 (16:12 +0200)
NEWS
main/main.c
main/php_open_temporary_file.c

diff --git a/NEWS b/NEWS
index 9f843c718c5ce2354952e3814e27bd5a2691de12..c1113d063d05a69482f70829474429570924ab6c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #69566 (Conditional jump or move depends on uninitialised value
     in extension trait). (jbboehr at gmail dot com)
+  . Fixed bug #66048 (temp. directory is cached during multiple requests).
+    (Julien)
 
 - Iconv:
   . Fixed bug #48147 (iconv with //IGNORE cuts the string). (Stas)
index 5d6abe3004cfd1d799315e2e98b9cfe78ccf3873..1f6bb4c590eef327a0d8eae22940dcfdb1a7056c 100644 (file)
@@ -1798,7 +1798,7 @@ void php_request_shutdown(void *dummy)
                }
        } zend_end_try();
 
-       /* 7.5 free last error information */
+       /* 7.5 free last error information and temp dir */
        if (PG(last_error_message)) {
                free(PG(last_error_message));
                PG(last_error_message) = NULL;
@@ -1807,6 +1807,7 @@ void php_request_shutdown(void *dummy)
                free(PG(last_error_file));
                PG(last_error_file) = NULL;
        }
+       php_shutdown_temporary_directory();
 
        /* 7. Shutdown scanner/executor/compiler and restore ini entries */
        zend_deactivate(TSRMLS_C);
@@ -2403,7 +2404,6 @@ void php_module_shutdown(TSRMLS_D)
 #endif
 
        php_output_shutdown();
-       php_shutdown_temporary_directory();
 
        module_initialized = 0;
 
index bba7874aceda1c513b145aab9d42b2e7fb075c10..260024625b736f5e08ed703d5bdfa13f3605d88f 100644 (file)
@@ -181,7 +181,7 @@ static char* temporary_directory;
 PHPAPI void php_shutdown_temporary_directory(void)
 {
        if (temporary_directory) {
-               free(temporary_directory);
+               efree(temporary_directory);
                temporary_directory = NULL;
        }
 }
@@ -202,10 +202,10 @@ PHPAPI const char* php_get_temporary_directory(TSRMLS_D)
                if (sys_temp_dir) {
                        int len = strlen(sys_temp_dir);
                        if (len >= 2 && sys_temp_dir[len - 1] == DEFAULT_SLASH) {
-                               temporary_directory = zend_strndup(sys_temp_dir, len - 1);
+                               temporary_directory = estrndup(sys_temp_dir, len - 1);
                                return temporary_directory;
                        } else if (len >= 1 && sys_temp_dir[len - 1] != DEFAULT_SLASH) {
-                               temporary_directory = zend_strndup(sys_temp_dir, len);
+                               temporary_directory = estrndup(sys_temp_dir, len);
                                return temporary_directory;
                        }
                }
@@ -222,9 +222,9 @@ PHPAPI const char* php_get_temporary_directory(TSRMLS_D)
                DWORD len = GetTempPath(sizeof(sTemp),sTemp);
                assert(0 < len);  /* should *never* fail! */
                if (sTemp[len - 1] == DEFAULT_SLASH) {
-                       temporary_directory = zend_strndup(sTemp, len - 1);
+                       temporary_directory = estrndup(sTemp, len - 1);
                } else {
-                       temporary_directory = zend_strndup(sTemp, len);
+                       temporary_directory = estrndup(sTemp, len);
                }
                return temporary_directory;
        }
@@ -236,9 +236,9 @@ PHPAPI const char* php_get_temporary_directory(TSRMLS_D)
                        int len = strlen(s);
 
                        if (s[len - 1] == DEFAULT_SLASH) {
-                               temporary_directory = zend_strndup(s, len - 1);
+                               temporary_directory = estrndup(s, len - 1);
                        } else {
-                               temporary_directory = zend_strndup(s, len);
+                               temporary_directory = estrndup(s, len);
                        }
 
                        return temporary_directory;
@@ -247,12 +247,12 @@ PHPAPI const char* php_get_temporary_directory(TSRMLS_D)
 #ifdef P_tmpdir
        /* Use the standard default temporary directory. */
        if (P_tmpdir) {
-               temporary_directory = strdup(P_tmpdir);
+               temporary_directory = estrdup(P_tmpdir);
                return temporary_directory;
        }
 #endif
        /* Shouldn't ever(!) end up here ... last ditch default. */
-       temporary_directory = strdup("/tmp");
+       temporary_directory = estrndup("/tmp", sizeof("/tmp"));
        return temporary_directory;
 #endif
 }