com php-src: Avoid unnecessary string copy: TSRM/tsrm_win3 2.c Zend/zend_virtual_cwd.c
| From: | Anatol Belski | Date: | Thu, 27 Apr 2017 14:03:12 +0000 |
| Subject: | com php-src: Avoid unnecessary string copy: TSRM/tsrm_win3 2.c Zend/zend_virtual_cwd.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97718@lists.php.net to get a copy of this message | ||
Commit: 6a010ad492ec82ce333fb4fee81fc46fc8e6a0a9
Author: Anatol Belski <ab@php.net> Thu, 27 Apr 2017 16:03:12 +0200
Parents: 24ae881080f8cfbb56e0981973d4474a831a3398
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6a010ad492ec82ce333fb4fee81fc46fc8e6a0a9
Log:
Avoid unnecessary string copy
which is the case when there's no impersonation.
Changed paths:
M TSRM/tsrm_win32.c
M Zend/zend_virtual_cwd.c
Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 4bd1fcb..bb277b4 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -115,14 +115,8 @@ char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_len,
si
size_t ptc_sid_len;
if (!pSid) {
- bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + 1);
- if (!bucket_key) {
- *key_len = 0;
- return NULL;
- }
- memcpy(bucket_key, pathname, pathname_len);
*key_len = pathname_len;
- return bucket_key;
+ return pathname;
}
if (!ConvertSidToStringSid(pSid, &ptcSid)) {
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index 2f9c46d..e9ffda7 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -539,7 +539,9 @@ static inline zend_ulong realpath_cache_key(const char *path, size_t path_len) /
h *= Z_UL(16777619);
h ^= *bucket_key++;
}
- HeapFree(GetProcessHeap(), 0, (LPVOID)bucket_key_start);
+ if (bucket_key_start != path) {
+ HeapFree(GetProcessHeap(), 0, (LPVOID)bucket_key_start);
+ }
return h;
}
/* }}} */