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

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=40598
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Müller 2018-08-31 02:29:05 +00:00 committed by Alexandre Julliard
parent 24f3d50ccc
commit bfe8510ec0
2 changed files with 21 additions and 6 deletions

View file

@ -1664,7 +1664,7 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF
if (dwFlags & ICU_DECODE)
{
WCHAR *url_tmp;
WCHAR *url_tmp, *buffer;
DWORD len = dwUrlLength + 1;
BOOL ret;
@ -1673,9 +1673,24 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF
SetLastError(ERROR_OUTOFMEMORY);
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)
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);
return ret;
}

View file

@ -816,9 +816,9 @@ static void InternetCrackUrlW_test(void)
comp.lpszUrlPath = urlpart;
comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
r = InternetCrackUrlW(url3, 0, ICU_DECODE, &comp);
todo_wine 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(urlpart[0] == 0, "urlpart should be empty\n");
ok(r, "InternetCrackUrlW failed unexpectedly\n");
ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host));
todo_wine ok(urlpart[0] == 0, "urlpart should be empty\n");
}
static void fill_url_components(URL_COMPONENTSA *lpUrlComponents)