[SHLWAPI] Sync with Wine Staging 2.9. CORE-13362
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:39:50 +0000 (22:39 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:39:50 +0000 (22:39 +0000)
98d0fa9 shlwapi: Use isalnumW() instead of isalnum() for WCHARs.
dfb846c shlwapi: Fixed error handling in StrRetToBufW.

svn path=/trunk/; revision=74847

reactos/dll/win32/shlwapi/string.c
reactos/dll/win32/shlwapi/url.c
reactos/media/doc/README.WINE

index 30a0a8d..64a7571 100644 (file)
@@ -1500,47 +1500,58 @@ HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, U
  */
 HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
 {
-        TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest, len, src, pidl);
+    TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest, len, src, pidl);
 
-       if (!src)
-       {
-         WARN("Invalid lpStrRet would crash under Win32!\n");
-         if (dest)
-           *dest = '\0';
-         return E_FAIL;
-       }
+    if (!dest || !len)
+        return E_FAIL;
 
-       if (!dest || !len)
-         return E_FAIL;
+    if (!src)
+    {
+        WARN("Invalid lpStrRet would crash under Win32!\n");
+        if (dest)
+            *dest = '\0';
+        return E_FAIL;
+    }
 
-       *dest = '\0';
+    *dest = '\0';
+
+    switch (src->uType) {
+    case STRRET_WSTR: {
+        size_t dst_len;
+        if (!src->u.pOleStr)
+            return E_FAIL;
+        dst_len = strlenW(src->u.pOleStr);
+        memcpy(dest, src->u.pOleStr, min(dst_len, len-1) * sizeof(WCHAR));
+        dest[min(dst_len, len-1)] = 0;
+        CoTaskMemFree(src->u.pOleStr);
+        if (len <= dst_len)
+        {
+            dest[0] = 0;
+            return E_NOT_SUFFICIENT_BUFFER;
+        }
+        break;
+    }
 
-       switch (src->uType)
-       {
-         case STRRET_WSTR:
-            lstrcpynW(dest, src->u.pOleStr, len);
-           CoTaskMemFree(src->u.pOleStr);
-           break;
+    case STRRET_CSTR:
+        if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ))
+            dest[len-1] = 0;
+        break;
 
-         case STRRET_CSTR:
-              if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ))
-                  dest[len-1] = 0;
-           break;
+    case STRRET_OFFSET:
+        if (pidl)
+       {
+            if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
+                                      dest, len ))
+                dest[len-1] = 0;
+        }
+        break;
 
-         case STRRET_OFFSET:
-           if (pidl)
-           {
-              if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
-                                        dest, len ))
-                  dest[len-1] = 0;
-           }
-           break;
+    default:
+        FIXME("unknown type!\n");
+        return E_NOTIMPL;
+    }
 
-         default:
-           FIXME("unknown type!\n");
-           return E_NOTIMPL;
-       }
-       return S_OK;
+    return S_OK;
 }
 
 /*************************************************************************
index 0b76974..9bb8df4 100644 (file)
@@ -794,7 +794,7 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
                process_case = 1;
                break;
            }
-            if (isalnum(*mrelative) && (*(mrelative + 1) == ':')) {
+            if (isalnumW(*mrelative) && (*(mrelative + 1) == ':')) {
                /* case that becomes "file:///" */
                strcpyW(preliminary, myfilestr);
                process_case = 1;
index 56eb2e9..031a418 100644 (file)
@@ -174,7 +174,7 @@ reactos/dll/win32/shdoclc             # Synced to WineStaging-1.9.11
 reactos/dll/win32/shdocvw             # Synced to WineStaging-2.2
 reactos/dll/win32/shell32             # Forked at Wine-20071011
 reactos/dll/win32/shfolder            # Synced to WineStaging-1.9.11
-reactos/dll/win32/shlwapi             # Synced to WineStaging-2.2
+reactos/dll/win32/shlwapi             # Synced to WineStaging-2.9
 reactos/dll/win32/slbcsp              # Synced to WineStaging-1.9.11
 reactos/dll/win32/snmpapi             # Synced to WineStaging-1.9.11
 reactos/dll/win32/softpub             # Synced to WineStaging-1.9.11