summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--main/main.c4
-rw-r--r--main/php_open_temporary_file.c18
3 files changed, 13 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index 9f843c718c..c1113d063d 100644
--- 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)
diff --git a/main/main.c b/main/main.c
index 5d6abe3004..1f6bb4c590 100644
--- a/main/main.c
+++ b/main/main.c
@@ -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;
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index bba7874ace..260024625b 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -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
}