]> granicus.if.org Git - php/commitdiff
Avoid unnecessary string copy
authorAnatol Belski <ab@php.net>
Thu, 27 Apr 2017 14:03:12 +0000 (16:03 +0200)
committerAnatol Belski <ab@php.net>
Thu, 27 Apr 2017 14:03:12 +0000 (16:03 +0200)
which is the case when there's no impersonation.

TSRM/tsrm_win32.c
Zend/zend_virtual_cwd.c

index 4bd1fcb930c3d02d3d36836211a45bf61b96e6d0..bb277b484b6fabc96c3046be94a1bc5e9dd11549 100644 (file)
@@ -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)) {
index 2f9c46d1e502a9f9646c015c9e7e35ca1e7efdc4..e9ffda7cc30e09536606b093e788eb4343ba5dbb 100644 (file)
@@ -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;
 }
 /* }}} */