com php-src: Move temporary allocation to the stack: TSRM/tsrm_win32.c
| From: | Anatol Belski | Date: | Sat, 09 Dec 2017 12:15:28 +0000 |
| Subject: | com php-src: Move temporary allocation to the stack: TSRM/tsrm_win32.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100539@lists.php.net to get a copy of this message | ||
Commit: 261ddb760a04fcdf8d3dd12a4745bc1f6c3f9424
Author: Anatol Belski <ab@php.net> Sat, 9 Dec 2017 13:15:28 +0100
Parents: f6e7fbc614311dd0efbcfb80c7da731e1b6f188d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=261ddb760a04fcdf8d3dd12a4745bc1f6c3f9424
Log:
Move temporary allocation to the stack
Changed paths:
M TSRM/tsrm_win32.c
Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 43d9f8e..902a693 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -207,10 +207,9 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
BOOL fAccess = FALSE;
realpath_cache_bucket * bucket = NULL;
- char * real_path = NULL;
+ char real_path[MAXPATHLEN] = {0};
if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) {
- real_path = (char *)malloc(MAXPATHLEN);
if(tsrm_realpath(pathname, real_path) == NULL) {
SET_ERRNO_FROM_WIN32_CODE(ERROR_FILE_NOT_FOUND);
return -1;
@@ -220,7 +219,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
PHP_WIN32_IOUTIL_INIT_W(pathname)
if (!pathw) {
- free(real_path);
return -1;
}
@@ -228,7 +226,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
int ret = php_win32_ioutil_access_w(pathw, mode);
if (0 > ret || X_OK == mode || F_OK == mode) {
PHP_WIN32_IOUTIL_CLEANUP_W()
- free(real_path);
return ret;
}
@@ -280,10 +277,9 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
if (CWDG(realpath_cache_size_limit)) {
t = time(0);
bucket = realpath_cache_lookup(pathname, strlen(pathname), t);
- if(bucket == NULL && real_path == NULL) {
+ if(bucket == NULL && !real_path[0]) {
/* We used the pathname directly. Call tsrm_realpath */
/* so that entry is created in realpath cache */
- real_path = (char *)malloc(MAXPATHLEN);
if(tsrm_realpath(pathname, real_path) != NULL) {
pathname = real_path;
bucket = realpath_cache_lookup(pathname, strlen(pathname), t);
@@ -367,10 +363,6 @@ Finished:
if(thread_token != NULL) {
CloseHandle(thread_token);
}
- if(real_path != NULL) {
- free(real_path);
- real_path = NULL;
- }
PHP_WIN32_IOUTIL_CLEANUP_W()
if(fAccess == FALSE) {