[PATCH 1/5] kernelbase: Include the null terminator in the length passed to WideCharToMultiByte() in UrlGetPartA().
Zebediah Figura
zfigura at codeweavers.com
Sun Feb 13 12:43:59 CST 2022
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/kernelbase/path.c | 4 ++--
dlls/shlwapi/tests/url.c | 8 +++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index 7cfff358fdb..15280a7ea4b 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -4148,10 +4148,10 @@ HRESULT WINAPI UrlGetPartA(const char *url, char *out, DWORD *out_len, DWORD par
return hr;
}
- len2 = WideCharToMultiByte(CP_ACP, 0, outW, len, NULL, 0, NULL, NULL);
+ len2 = WideCharToMultiByte(CP_ACP, 0, outW, len + 1, NULL, 0, NULL, NULL);
if (len2 > *out_len)
{
- *out_len = len2 + 1;
+ *out_len = len2;
heap_free(inW);
return E_POINTER;
}
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index 212ee039a0b..b4b66aec2f1 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -782,7 +782,7 @@ static void test_UrlGetPart(void)
size = 1;
strcpy(buffer, "x");
hr = UrlGetPartA(url, buffer, &size, part, flags);
- todo_wine_if (tests[i].todo_hr || !strcmp(url, "http://host?a:b@c:d"))
+ todo_wine_if (tests[i].todo_hr)
{
if (tests[i].hr == S_OK)
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
@@ -807,11 +807,9 @@ static void test_UrlGetPart(void)
}
else
{
- todo_wine_if (hr == S_OK)
- ok(size == 1, "Got size %u.\n", size);
+ ok(size == 1, "Got size %u.\n", size);
}
- todo_wine_if (hr == S_OK)
- ok(!strcmp(buffer, "x"), "Got result %s.\n", debugstr_a(buffer));
+ ok(!strcmp(buffer, "x"), "Got result %s.\n", debugstr_a(buffer));
}
size = sizeof(buffer);
--
2.34.1
More information about the wine-devel
mailing list