From 6a010ad492ec82ce333fb4fee81fc46fc8e6a0a9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 27 Apr 2017 16:03:12 +0200 Subject: [PATCH] Avoid unnecessary string copy which is the case when there's no impersonation. --- TSRM/tsrm_win32.c | 8 +------- Zend/zend_virtual_cwd.c | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) 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; } /* }}} */ -- 2.50.1