Commit 267a5658 authored by Bernhard Übelacker's avatar Bernhard Übelacker Committed by Alexandre Julliard

wininet: Avoid crash in InternetCreateUrl with scheme unknown.

parent ceea01b1
......@@ -4405,6 +4405,12 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
{
LPCWSTR scheme;
if (lpUrlComponents->nScheme == INTERNET_SCHEME_UNKNOWN)
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
nScheme = lpUrlComponents->nScheme;
if (nScheme == INTERNET_SCHEME_DEFAULT)
......
......@@ -1231,6 +1231,21 @@ static void InternetCreateUrlA_test(void)
ok(!strcmp(szUrl, CREATE_URL13), "Expected \"%s\", got \"%s\"\n", CREATE_URL13, szUrl);
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
fill_url_components(&urlComp);
urlComp.lpszScheme = NULL;
urlComp.dwSchemeLength = 0;
urlComp.nScheme = INTERNET_SCHEME_UNKNOWN;
len = 256;
szUrl = HeapAlloc(GetProcessHeap(), 0, len);
SetLastError(0xdeadbeef);
ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
HeapFree(GetProcessHeap(), 0, szUrl);
}
static void InternetCanonicalizeUrl_test(void)
......
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