diff options
author | Anatol Belski <ab@php.net> | 2017-12-09 13:15:28 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-12-09 13:15:28 +0100 |
commit | 261ddb760a04fcdf8d3dd12a4745bc1f6c3f9424 (patch) | |
tree | b4dc363a1abea9e74d594ca4ca37abf00cfd5dbf /TSRM | |
parent | f6e7fbc614311dd0efbcfb80c7da731e1b6f188d (diff) | |
download | php-git-261ddb760a04fcdf8d3dd12a4745bc1f6c3f9424.tar.gz |
Move temporary allocation to the stack
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/tsrm_win32.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 43d9f8e572..902a693ccc 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) { |