Commit 1747b0b1 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

kernelbase: Do not initialize output params on failure in UrlGetPart().

parent 0df41c35
......@@ -4321,8 +4321,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
if (!url || !out || !out_len || !*out_len)
return E_INVALIDARG;
*out = '\0';
addr = wcschr(url, ':');
if (!addr)
scheme = URL_SCHEME_UNKNOWN;
......@@ -4337,6 +4335,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
flags &= ~URL_PARTFLAG_KEEPSCHEME;
if (!pl.scheme_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4358,18 +4357,19 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_SCHEME_SNEWS:
break;
default:
*out_len = 0;
return E_FAIL;
}
if (scheme == URL_SCHEME_FILE && (!pl.hostname_len || (pl.hostname_len == 1 && *(pl.hostname + 1) == ':')))
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
if (!pl.hostname_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4380,6 +4380,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_USERNAME:
if (!pl.username_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4390,6 +4391,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_PASSWORD:
if (!pl.password_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4400,6 +4402,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_PORT:
if (!pl.port_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4411,6 +4414,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
flags &= ~URL_PARTFLAG_KEEPSCHEME;
if (!pl.query_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
......@@ -4419,17 +4423,13 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
break;
default:
*out_len = 0;
return E_INVALIDARG;
}
if (flags == URL_PARTFLAG_KEEPSCHEME && scheme != URL_SCHEME_FILE)
{
if (!pl.scheme || !pl.scheme_len)
{
*out_len = 0;
return E_FAIL;
}
schaddr = pl.scheme;
schsize = pl.scheme_len;
if (*out_len < schsize + size + 2)
......
......@@ -845,7 +845,7 @@ static void test_UrlGetPart(void)
ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#x.\n", hr);
}
if (hr == S_OK)
if (SUCCEEDED(hr))
{
ok(!size, "Got size %u.\n", size);
ok(!buffer[0], "Got result %s.\n", debugstr_a(buffer));
......@@ -862,9 +862,9 @@ static void test_UrlGetPart(void)
}
else
{
todo_wine ok(size == 1, "Got size %u.\n", size);
ok(size == 1, "Got size %u.\n", size);
}
todo_wine ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
}
size = ARRAY_SIZE(bufferW);
......@@ -880,8 +880,11 @@ static void test_UrlGetPart(void)
}
else
{
todo_wine ok(size == ARRAY_SIZE(bufferW), "Got size %u.\n", size);
todo_wine ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
todo_wine_if (strchr(url, '"') && part == URL_PART_USERNAME)
{
ok(size == ARRAY_SIZE(bufferW), "Got size %u.\n", size);
ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
}
}
winetest_pop_context();
......
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