Index: /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp	(revision 39606)
+++ /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp	(revision 39607)
@@ -113,5 +113,5 @@
 }
 
-static MAPPING *vbsfMappingGetByName (PRTUTF16 utf16Name, SHFLROOT *pRoot)
+static MAPPING *vbsfMappingGetByName (PRTUTF16 pwszName, SHFLROOT *pRoot)
 {
     unsigned i;
@@ -121,5 +121,5 @@
         if (FolderMapping[i].fValid == true)
         {
-            if (!RTUtf16LocaleICmp(FolderMapping[i].pMapName->String.ucs2, utf16Name))
+            if (!RTUtf16LocaleICmp(FolderMapping[i].pMapName->String.ucs2, pwszName))
             {
                 SHFLROOT root = vbsfMappingGetRootFromIndex(i);
@@ -217,17 +217,14 @@
         if (FolderMapping[i].fValid == false)
         {
-            FolderMapping[i].pFolderName = (PSHFLSTRING)RTMemAlloc(ShflStringSizeOfBuffer(pFolderName));
-            Assert(FolderMapping[i].pFolderName);
-            if (FolderMapping[i].pFolderName == NULL)
+            int rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &FolderMapping[i].pszFolderName);
+            AssertRCReturn(rc, rc);
+
+            FolderMapping[i].pMapName = (PSHFLSTRING)RTMemAlloc(ShflStringSizeOfBuffer(pMapName));
+            if (!FolderMapping[i].pMapName)
+            {
+                RTStrFree(FolderMapping[i].pszFolderName);
+                AssertFailed();
                 return VERR_NO_MEMORY;
-
-            FolderMapping[i].pFolderName->u16Length = pFolderName->u16Length;
-            FolderMapping[i].pFolderName->u16Size   = pFolderName->u16Size;
-            memcpy(FolderMapping[i].pFolderName->String.ucs2, pFolderName->String.ucs2, pFolderName->u16Size);
-
-            FolderMapping[i].pMapName = (PSHFLSTRING)RTMemAlloc(ShflStringSizeOfBuffer(pMapName));
-            Assert(FolderMapping[i].pMapName);
-            if (FolderMapping[i].pMapName == NULL)
-                return VERR_NO_MEMORY;
+            }
 
             FolderMapping[i].pMapName->u16Length = pMapName->u16Length;
@@ -242,20 +239,14 @@
             /* Check if the host file system is case sensitive */
             RTFSPROPERTIES prop;
-            char *utf8Root, *asciiroot;
-
-            int rc = RTUtf16ToUtf8(FolderMapping[i].pFolderName->String.ucs2, &utf8Root);
-            AssertRC(rc);
-
+            char *pszAsciiRoot;
+
+            rc = RTStrUtf8ToCurrentCP(&pszAsciiRoot, FolderMapping[i].pszFolderName);
             if (RT_SUCCESS(rc))
             {
-                rc = RTStrUtf8ToCurrentCP(&asciiroot, utf8Root);
-                if (RT_SUCCESS(rc))
-                {
-                    rc = RTFsQueryProperties(asciiroot, &prop);
-                    AssertRC(rc);
-                    RTStrFree(asciiroot);
-                }
-                RTStrFree(utf8Root);
+                rc = RTFsQueryProperties(pszAsciiRoot, &prop);
+                AssertRC(rc);
+                RTStrFree(pszAsciiRoot);
             }
+
             FolderMapping[i].fHostCaseSensitive = RT_SUCCESS(rc) ? prop.fCaseSensitive : false;
             vbsfRootHandleAdd(i);
@@ -302,9 +293,9 @@
                 }
 
-                RTMemFree(FolderMapping[i].pFolderName);
+                RTStrFree(FolderMapping[i].pszFolderName);
                 RTMemFree(FolderMapping[i].pMapName);
-                FolderMapping[i].pFolderName = NULL;
-                FolderMapping[i].pMapName    = NULL;
-                FolderMapping[i].fValid      = false;
+                FolderMapping[i].pszFolderName = NULL;
+                FolderMapping[i].pMapName      = NULL;
+                FolderMapping[i].fValid        = false;
                 vbsfRootHandleRemove(i);
                 break;
@@ -322,15 +313,9 @@
 }
 
-PCRTUTF16 vbsfMappingsQueryHostRoot(SHFLROOT root, uint32_t *pcbRoot)
-{
-    MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
-    if (pFolderMapping == NULL)
-    {
-        AssertFailed();
-        return NULL;
-    }
-
-    *pcbRoot = pFolderMapping->pFolderName->u16Size;
-    return &pFolderMapping->pFolderName->String.ucs2[0];
+const char* vbsfMappingsQueryHostRoot(SHFLROOT root)
+{
+    MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
+    AssertReturn(pFolderMapping, NULL);
+    return pFolderMapping->pszFolderName;
 }
 
@@ -338,10 +323,5 @@
 {
     MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
-    if (pFolderMapping == NULL)
-    {
-        AssertFailed();
-        return false;
-    }
-
+    AssertReturn(pFolderMapping, false);
     return pFolderMapping->fGuestCaseSensitive;
 }
@@ -350,10 +330,5 @@
 {
     MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
-    if (pFolderMapping == NULL)
-    {
-        AssertFailed();
-        return false;
-    }
-
+    AssertReturn(pFolderMapping, false);
     return pFolderMapping->fHostCaseSensitive;
 }
@@ -534,5 +509,5 @@
 #endif
 int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName,
-                  RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot)
+                  RTUTF16 pwszDelimiter, bool fCaseSensitive, SHFLROOT *pRoot)
 {
     MAPPING *pFolderMapping = NULL;
@@ -549,9 +524,9 @@
     if (pClient->PathDelimiter == 0)
     {
-        pClient->PathDelimiter = delimiter;
+        pClient->PathDelimiter = pwszDelimiter;
     }
     else
     {
-        Assert(delimiter == pClient->PathDelimiter);
+        Assert(pwszDelimiter == pClient->PathDelimiter);
     }
 
Index: /trunk/src/VBox/HostServices/SharedFolders/mappings.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/mappings.h	(revision 39606)
+++ /trunk/src/VBox/HostServices/SharedFolders/mappings.h	(revision 39607)
@@ -23,5 +23,5 @@
 typedef struct
 {
-    PSHFLSTRING pFolderName;
+    char        *pszFolderName;
     PSHFLSTRING pMapName;
     uint32_t    cMappings;
@@ -49,5 +49,5 @@
 int vbsfUnmapFolder(PSHFLCLIENTDATA pClient, SHFLROOT root);
 
-PCRTUTF16 vbsfMappingsQueryHostRoot(SHFLROOT root, uint32_t *pcbRoot);
+const char* vbsfMappingsQueryHostRoot(SHFLROOT root);
 bool vbsfIsGuestMappingCaseSensitive(SHFLROOT root);
 bool vbsfIsHostMappingCaseSensitive(SHFLROOT root);
Index: /trunk/src/VBox/HostServices/SharedFolders/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/service.cpp	(revision 39606)
+++ /trunk/src/VBox/HostServices/SharedFolders/service.cpp	(revision 39607)
@@ -28,5 +28,6 @@
 #include <VBox/vmm/pdmifs.h>
 
-#define SHFL_SSM_VERSION        2
+#define SHFL_SSM_VERSION_FOLDERNAME_UTF16   2
+#define SHFL_SSM_VERSION                    3
 
 
@@ -146,9 +147,9 @@
             uint32_t len;
 
-            len = ShflStringSizeOfBuffer(pFolderMapping->pFolderName);
+            len = strlen(pFolderMapping->pszFolderName);
             rc = SSMR3PutU32(pSSM, len);
             AssertRCReturn(rc, rc);
 
-            rc = SSMR3PutMem(pSSM, pFolderMapping->pFolderName, len);
+            rc = SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
             AssertRCReturn(rc, rc);
 
@@ -184,5 +185,6 @@
     AssertRCReturn(rc, rc);
 
-    if (version != SHFL_SSM_VERSION)
+    if (   version > SHFL_SSM_VERSION
+        || version < SHFL_SSM_VERSION_FOLDERNAME_UTF16)
         return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
 
@@ -219,5 +221,5 @@
         {
             uint32_t cbFolderName;
-            PSHFLSTRING pFolderName;
+            char *pszFolderName;
 
             uint32_t cbMapName;
@@ -228,9 +230,25 @@
             AssertRCReturn(rc, rc);
 
-            pFolderName = (PSHFLSTRING)RTMemAlloc(cbFolderName);
-            AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
-
-            rc = SSMR3GetMem(pSSM, pFolderName, cbFolderName);
-            AssertRCReturn(rc, rc);
+            if (version == SHFL_SSM_VERSION_FOLDERNAME_UTF16)
+            {
+                PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cbFolderName);
+                AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
+
+                rc = SSMR3GetMem(pSSM, pFolderName, cbFolderName);
+                AssertRCReturn(rc, rc);
+
+                rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName);
+                RTMemFree(pFolderName);
+                AssertRCReturn(rc, rc);
+            }
+            else
+            {
+                pszFolderName = (char*)RTStrAlloc(cbFolderName);
+                AssertReturn(pszFolderName, VERR_NO_MEMORY);
+
+                rc = SSMR3GetStrZ(pSSM, mapping.pszFolderName, cbFolderName);
+                AssertRCReturn(rc, rc);
+                mapping.pszFolderName = pszFolderName;
+            }
 
             /* Load the map name. */
@@ -250,5 +268,5 @@
             AssertRCReturn(rc, rc);
 
-            mapping.pFolderName = pFolderName;
+            mapping.pszFolderName = pszFolderName;
             mapping.pMapName = pMapName;
 
@@ -257,5 +275,5 @@
 
             RTMemFree(pMapName);
-            RTMemFree(pFolderName);
+            RTStrFree(pszFolderName);
 
             AssertRCReturn(rc, rc);
Index: /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp	(revision 39606)
+++ /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp	(revision 39607)
@@ -253,12 +253,10 @@
 {
     int rc = VINF_SUCCESS;
-
     char *pszFullPath = NULL;
-
-    /* Query UCS2 root prefix for the path, cbRoot is the length in bytes including trailing (RTUTF16)0. */
-    uint32_t cbRoot = 0;
-    PCRTUTF16 pwszRoot = vbsfMappingsQueryHostRoot(root, &cbRoot);
-
-    if (!pwszRoot || cbRoot == 0)
+    size_t cbRoot;
+    const char *pszRoot = vbsfMappingsQueryHostRoot(root);
+
+    if (   !pszRoot
+        || !(cbRoot = strlen(pszRoot)))
     {
         Log(("vbsfBuildFullPath: invalid root!\n"));
@@ -268,6 +266,4 @@
     if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
     {
-        char *utf8Root;
-
         /* Verify that the path is under the root directory. */
         rc = vbsfPathCheck((const char *)&pPath->String.utf8[0], pPath->u16Length);
@@ -275,15 +271,6 @@
         if (RT_SUCCESS(rc))
         {
-            rc = RTUtf16ToUtf8(pwszRoot, &utf8Root);
-        }
-
-        if (RT_SUCCESS(rc))
-        {
-            size_t cbUtf8Root, cbUtf8FullPath;
-            char *utf8FullPath;
-
-            cbUtf8Root = strlen(utf8Root);
-            cbUtf8FullPath = cbUtf8Root + 1 + pPath->u16Length + 1;
-            utf8FullPath = (char *) RTMemAllocZ(cbUtf8FullPath);
+            size_t cbUtf8FullPath = cbRoot + 1 + pPath->u16Length + 1;
+            char *utf8FullPath = (char *) RTMemAllocZ(cbUtf8FullPath);
 
             if (!utf8FullPath)
@@ -295,18 +282,13 @@
             else
             {
-                memcpy(utf8FullPath, utf8Root, cbUtf8Root);
-                memcpy(utf8FullPath + cbUtf8Root + 1,
-                       &pPath->String.utf8[0],
-                       pPath->u16Length);
-
-                utf8FullPath[cbUtf8Root] = '/';
+                memcpy(utf8FullPath, pszRoot, cbRoot);
+                utf8FullPath[cbRoot] = '/';
+                memcpy(utf8FullPath + cbRoot + 1, &pPath->String.utf8[0], pPath->u16Length);
                 utf8FullPath[cbUtf8FullPath - 1] = 0;
                 pszFullPath = utf8FullPath;
 
                 if (pcbFullPathRoot)
-                    *pcbFullPathRoot = (uint32_t)cbUtf8Root; /* Must index the path delimiter.  */
-            }
-
-            RTStrFree(utf8Root);
+                    *pcbFullPathRoot = (uint32_t)cbRoot; /* Must index the path delimiter. */
+            }
         }
         else
@@ -337,5 +319,6 @@
         }
 
-        ::CFStringAppendCharacters(inStr, (UniChar*)pPathParameter->String.ucs2, pPathParameter->u16Length / sizeof(pPathParameter->String.ucs2[0]));
+        ::CFStringAppendCharacters(inStr, (UniChar*)pPathParameter->String.ucs2,
+                                   pPathParameter->u16Length / sizeof(pPathParameter->String.ucs2[0]));
         ::CFStringNormalize(inStr, kCFStringNormalizationFormD);
         ucs2Length = ::CFStringGetLength(inStr);
@@ -351,15 +334,12 @@
 #endif
         /* Client sends us UCS2, so convert it to UTF8. */
-        Log(("Root %ls path %.*ls\n", pwszRoot, pPath->u16Length/sizeof(pPath->String.ucs2[0]), pPath->String.ucs2));
-
-        /* Allocate buffer that will be able to contain
-         * the root prefix and the pPath converted to UTF8.
-         * Expect a 2 bytes UCS2 to be converted to 8 bytes UTF8
-         * in worst case.
+        Log(("Root %s path %.*ls\n", pszRoot, pPath->u16Length/sizeof(pPath->String.ucs2[0]), pPath->String.ucs2));
+
+        /* Allocate buffer that will be able to contain the root prefix and
+         * the pPath converted to UTF8. Expect a 2 bytes UCS2 to be converted
+         * to 8 bytes UTF8 in the worst case.
          */
-        uint32_t cbFullPath = (cbRoot/sizeof(RTUTF16) + ShflStringLength(pPath)) * 4;
-
+        uint32_t cbFullPath = (cbRoot + ShflStringLength(pPath)) * 4;
         pszFullPath = (char *)RTMemAllocZ(cbFullPath);
-
         if (!pszFullPath)
         {
@@ -368,54 +348,42 @@
         else
         {
-            uint32_t cb = cbFullPath;
-
-            rc = RTUtf16ToUtf8Ex(pwszRoot, RTSTR_MAX, &pszFullPath, cb, NULL);
-            if (RT_FAILURE(rc))
-            {
-                AssertFailed();
-#ifdef RT_OS_DARWIN
-                RTMemFree(pPath);
-                pPath = pPathParameter;
-#endif
-                return rc;
-            }
-
-            char *dst = pszFullPath;
-
-            cbRoot = (uint32_t)strlen(dst);
-            if (dst[cbRoot - 1] != RTPATH_DELIMITER)
-            {
-                dst[cbRoot] = RTPATH_DELIMITER;
-                cbRoot++;
+            memcpy(pszFullPath, pszRoot, cbRoot + 1);
+            char *pszDst = pszFullPath;
+            size_t cbDst = strlen(pszDst);
+            size_t cb    = cbFullPath;
+            if (pszDst[cbDst - 1] != RTPATH_DELIMITER)
+            {
+                pszDst[cbDst] = RTPATH_DELIMITER;
+                cbDst++;
             }
 
             if (pcbFullPathRoot)
-                *pcbFullPathRoot = cbRoot - 1; /* Must index the path delimiter.  */
-
-            dst   += cbRoot;
-            cb    -= cbRoot;
+                *pcbFullPathRoot = cbDst - 1; /* Must index the path delimiter.  */
+
+            pszDst += cbDst;
+            cb     -= cbDst;
 
             if (pPath->u16Length)
             {
                 /* Convert and copy components. */
-                PRTUTF16 src = &pPath->String.ucs2[0];
+                PRTUTF16 pwszSrc = &pPath->String.ucs2[0];
 
                 /* Correct path delimiters */
                 if (pClient->PathDelimiter != RTPATH_DELIMITER)
                 {
-                    LogFlow(("Correct path delimiter in %ls\n", src));
-                    while (*src)
+                    LogFlow(("Correct path delimiter in %ls\n", pwszSrc));
+                    while (*pwszSrc)
                     {
-                        if (*src == pClient->PathDelimiter)
-                            *src = RTPATH_DELIMITER;
-                        src++;
+                        if (*pwszSrc == pClient->PathDelimiter)
+                            *pwszSrc = RTPATH_DELIMITER;
+                        pwszSrc++;
                     }
-                    src = &pPath->String.ucs2[0];
-                    LogFlow(("Corrected string %ls\n", src));
+                    pwszSrc = &pPath->String.ucs2[0];
+                    LogFlow(("Corrected string %ls\n", pwszSrc));
                 }
-                if (*src == RTPATH_DELIMITER)
-                    src++;  /* we already appended a delimiter to the first part */
-
-                rc = RTUtf16ToUtf8Ex(src, RTSTR_MAX, &dst, cb, NULL);
+                if (*pwszSrc == RTPATH_DELIMITER)
+                    pwszSrc++;  /* we already appended a delimiter to the first part */
+
+                rc = RTUtf16ToUtf8Ex(pwszSrc, RTSTR_MAX, &pszDst, cb, NULL);
                 if (RT_FAILURE(rc))
                 {
@@ -428,9 +396,8 @@
                 }
 
-                uint32_t l = (uint32_t)strlen(dst);
+                cbDst = (uint32_t)strlen(pszDst);
 
                 /* Verify that the path is under the root directory. */
-                rc = vbsfPathCheck(dst, l);
-
+                rc = vbsfPathCheck(pszDst, cbDst);
                 if (RT_FAILURE(rc))
                 {
@@ -442,6 +409,6 @@
                 }
 
-                cb -= l;
-                dst += l;
+                cb     -= cbDst;
+                pszDst += cbDst;
 
                 Assert(cb > 0);
@@ -449,5 +416,5 @@
 
             /* Nul terminate the string */
-            *dst = 0;
+            *pszDst = 0;
         }
 #ifdef RT_OS_DARWIN
@@ -469,32 +436,32 @@
             {
                 /* strip off the last path component, that has to be preserved: contains the wildcard(s) or a 'rename' target. */
-                uint32_t len = (uint32_t)strlen(pszFullPath);
-                char    *src = pszFullPath + len - 1;
-
-                while(src > pszFullPath)
+                size_t cb = strlen(pszFullPath);
+                char *pszSrc = pszFullPath + cb - 1;
+
+                while (pszSrc > pszFullPath)
                 {
-                    if (*src == RTPATH_DELIMITER)
+                    if (*pszSrc == RTPATH_DELIMITER)
                         break;
-                    src--;
+                    pszSrc--;
                 }
-                if (*src == RTPATH_DELIMITER)
+                if (*pszSrc == RTPATH_DELIMITER)
                 {
                     bool fHaveWildcards = false;
-                    char *temp = src;
-
-                    while(*temp)
+                    char *psz = pszSrc;
+
+                    while (*psz)
                     {
-                        char uc = *temp;
-                        if (uc == '*' || uc == '?' || uc == '>' || uc == '<' || uc == '"')
+                        char ch = *psz;
+                        if (ch == '*' || ch == '?' || ch == '>' || ch == '<' || ch == '"')
                         {
                             fHaveWildcards = true;
                             break;
                         }
-                        temp++;
+                        psz++;
                     }
 
                     if (fHaveWildcards || fPreserveLastComponent)
                     {
-                        pszLastComponent = src;
+                        pszLastComponent = pszSrc;
                         *pszLastComponent = 0;
                     }
@@ -506,23 +473,23 @@
             if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND)
             {
-                uint32_t len = (uint32_t)strlen(pszFullPath);
-                char    *src = pszFullPath + len - 1;
+                size_t cb = strlen(pszFullPath);
+                char   *pszSrc = pszFullPath + cb - 1;
 
                 Log(("Handle case insensitive guest fs on top of host case sensitive fs for %s\n", pszFullPath));
 
                 /* Find partial path that's valid */
-                while(src > pszFullPath)
+                while (pszSrc > pszFullPath)
                 {
-                    if (*src == RTPATH_DELIMITER)
+                    if (*pszSrc == RTPATH_DELIMITER)
                     {
-                        *src = 0;
+                        *pszSrc = 0;
                         rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient));
-                        *src = RTPATH_DELIMITER;
+                        *pszSrc = RTPATH_DELIMITER;
                         if (rc == VINF_SUCCESS)
                         {
 #ifdef DEBUG
-                            *src = 0;
+                            *pszSrc = 0;
                             Log(("Found valid partial path %s\n", pszFullPath));
-                            *src = RTPATH_DELIMITER;
+                            *pszSrc = RTPATH_DELIMITER;
 #endif
                             break;
@@ -530,31 +497,31 @@
                     }
 
-                    src--;
+                    pszSrc--;
                 }
-                Assert(*src == RTPATH_DELIMITER && RT_SUCCESS(rc));
-                if (    *src == RTPATH_DELIMITER
+                Assert(*pszSrc == RTPATH_DELIMITER && RT_SUCCESS(rc));
+                if (    *pszSrc == RTPATH_DELIMITER
                     &&  RT_SUCCESS(rc))
                 {
-                    src++;
+                    pszSrc++;
                     for (;;)
                     {
-                        char *end = src;
+                        char *pszEnd = pszSrc;
                         bool fEndOfString = true;
 
-                        while(*end)
+                        while (*pszEnd)
                         {
-                            if (*end == RTPATH_DELIMITER)
+                            if (*pszEnd == RTPATH_DELIMITER)
                                 break;
-                            end++;
+                            pszEnd++;
                         }
 
-                        if (*end == RTPATH_DELIMITER)
+                        if (*pszEnd == RTPATH_DELIMITER)
                         {
                             fEndOfString = false;
-                            *end = 0;
-                            rc = RTPathQueryInfoEx(src, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient));
+                            *pszEnd = 0;
+                            rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient));
                             Assert(rc == VINF_SUCCESS || rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND);
                         }
-                        else if (end == src)
+                        else if (pszEnd == pszSrc)
                             rc = VINF_SUCCESS;  /* trailing delimiter */
                         else
@@ -564,9 +531,9 @@
                         {
                             /* path component is invalid; try to correct the casing */
-                            rc = vbsfCorrectCasing(pClient, pszFullPath, src);
+                            rc = vbsfCorrectCasing(pClient, pszFullPath, pszSrc);
                             if (RT_FAILURE(rc))
                             {
                                 if (!fEndOfString)
-                                    *end = RTPATH_DELIMITER; /* restore the original full path */
+                                    *pszEnd = RTPATH_DELIMITER; /* restore the original full path */
                                 break;
                             }
@@ -576,6 +543,6 @@
                             break;
 
-                        *end = RTPATH_DELIMITER;
-                        src = end + 1;
+                        *pszEnd = RTPATH_DELIMITER;
+                        pszSrc = pszEnd + 1;
                     }
                     if (RT_FAILURE(rc))
@@ -1593,5 +1560,5 @@
     }
 
-    while(cbBufferOrg)
+    while (cbBufferOrg)
     {
         size_t cbDirEntrySize = cbDirEntry;
