From: Anatol Belski Date: Thu, 27 Apr 2017 14:03:12 +0000 (+0200) Subject: Avoid unnecessary string copy X-Git-Tag: php-7.2.0alpha2~15^2~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a010ad492ec82ce333fb4fee81fc46fc8e6a0a9;p=php Avoid unnecessary string copy which is the case when there's no impersonation. --- diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 4bd1fcb930..bb277b484b 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 2f9c46d1e5..e9ffda7cc3 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; } /* }}} */