Commit bfe8510e authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

wininet: Resize buffer when call to InternetCanonicalizeUrlW fails in InternetCrackUrlW.

parent 24f3d50c
...@@ -1664,7 +1664,7 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF ...@@ -1664,7 +1664,7 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF
if (dwFlags & ICU_DECODE) if (dwFlags & ICU_DECODE)
{ {
WCHAR *url_tmp; WCHAR *url_tmp, *buffer;
DWORD len = dwUrlLength + 1; DWORD len = dwUrlLength + 1;
BOOL ret; BOOL ret;
...@@ -1673,9 +1673,24 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF ...@@ -1673,9 +1673,24 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return FALSE; return FALSE;
} }
ret = InternetCanonicalizeUrlW(url_tmp, url_tmp, &len, ICU_DECODE | ICU_NO_ENCODE);
buffer = url_tmp;
ret = InternetCanonicalizeUrlW(url_tmp, buffer, &len, ICU_DECODE | ICU_NO_ENCODE);
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
buffer = heap_alloc(len * sizeof(WCHAR));
if (!buffer)
{
SetLastError(ERROR_OUTOFMEMORY);
heap_free(url_tmp);
return FALSE;
}
ret = InternetCanonicalizeUrlW(url_tmp, buffer, &len, ICU_DECODE | ICU_NO_ENCODE);
}
if (ret) if (ret)
ret = InternetCrackUrlW(url_tmp, len, dwFlags & ~ICU_DECODE, lpUC); ret = InternetCrackUrlW(buffer, len, dwFlags & ~ICU_DECODE, lpUC);
if (buffer != url_tmp) heap_free(buffer);
heap_free(url_tmp); heap_free(url_tmp);
return ret; return ret;
} }
......
...@@ -816,9 +816,9 @@ static void InternetCrackUrlW_test(void) ...@@ -816,9 +816,9 @@ static void InternetCrackUrlW_test(void)
comp.lpszUrlPath = urlpart; comp.lpszUrlPath = urlpart;
comp.dwUrlPathLength = ARRAY_SIZE(urlpart); comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
r = InternetCrackUrlW(url3, 0, ICU_DECODE, &comp); r = InternetCrackUrlW(url3, 0, ICU_DECODE, &comp);
todo_wine ok(r, "InternetCrackUrlW failed unexpectedly\n"); ok(r, "InternetCrackUrlW failed unexpectedly\n");
todo_wine ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host)); ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host));
ok(urlpart[0] == 0, "urlpart should be empty\n"); todo_wine ok(urlpart[0] == 0, "urlpart should be empty\n");
} }
static void fill_url_components(URL_COMPONENTSA *lpUrlComponents) static void fill_url_components(URL_COMPONENTSA *lpUrlComponents)
......
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