Commit 2b99331e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shlwapi: Fixed handling A->W buffer in UrlCanonicalizeA (valgrind).

parent 42874c62
......@@ -42,6 +42,21 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR,HMODULE,DWORD,LPCWSTR,LPWSTR,DWORD);
WINE_DEFAULT_DEBUG_CHANNEL(shell);
static inline WCHAR *heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;
if(str) {
DWORD len;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
}
return ret;
}
/* The following schemes were identified in the native version of
* SHLWAPI.DLL version 5.50
*/
......@@ -234,7 +249,6 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
{
LPWSTR url, canonical;
HRESULT ret;
DWORD len;
TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_a(pszUrl), pszCanonicalized,
pcchCanonicalized, dwFlags, pcchCanonicalized ? *pcchCanonicalized : -1);
......@@ -242,8 +256,7 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized || !*pcchCanonicalized)
return E_INVALIDARG;
len = strlen(pszUrl)+1;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
url = heap_strdupAtoW(pszUrl);
canonical = HeapAlloc(GetProcessHeap(), 0, *pcchCanonicalized*sizeof(WCHAR));
if(!url || !canonical) {
HeapFree(GetProcessHeap(), 0, url);
......@@ -251,13 +264,12 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
return E_OUTOFMEMORY;
}
MultiByteToWideChar(0, 0, pszUrl, -1, url, len);
ret = UrlCanonicalizeW(url, canonical, pcchCanonicalized, dwFlags);
if(ret == S_OK)
WideCharToMultiByte(0, 0, canonical, -1, pszCanonicalized,
*pcchCanonicalized+1, 0, 0);
HeapFree(GetProcessHeap(), 0, url);
HeapFree(GetProcessHeap(), 0, canonical);
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment