Commit 43bff70a authored by Lei Zhang's avatar Lei Zhang Committed by Alexandre Julliard

shlwapi: Check more arguments to UrlEscapeA.

parent 32fda211
......@@ -461,23 +461,17 @@ static void test_UrlEscape(void)
ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
todo_wine {
ok(size == 0, "got %d, expected %d\n", size, 0);
}
ok(size == 0, "got %d, expected %d\n", size, 0);
size = 0;
ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY);
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
todo_wine {
ok(size == 0, "got %d, expected %d\n", size, 0);
}
ok(size == 0, "got %d, expected %d\n", size, 0);
size = 1;
ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
todo_wine {
ok(size == 1, "got %d, expected %d\n", size, 1);
}
ok(size == 1, "got %d, expected %d\n", size, 1);
size = 1;
ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, NULL, URL_ESCAPE_SPACES_ONLY);
......
......@@ -843,7 +843,7 @@ HRESULT WINAPI UrlEscapeA(
HRESULT ret;
DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
if (!pcchEscaped)
if (!pszEscaped || !pcchEscaped || !*pcchEscaped)
return E_INVALIDARG;
if(!RtlCreateUnicodeStringFromAsciiz(&urlW, pszUrl))
......@@ -854,7 +854,7 @@ HRESULT WINAPI UrlEscapeA(
}
if(ret == S_OK) {
RtlUnicodeToMultiByteSize(&lenA, escapedW, lenW * sizeof(WCHAR));
if(pszEscaped && *pcchEscaped > lenA) {
if(*pcchEscaped > lenA) {
RtlUnicodeToMultiByteN(pszEscaped, *pcchEscaped - 1, &lenA, escapedW, lenW * sizeof(WCHAR));
pszEscaped[lenA] = 0;
*pcchEscaped = lenA;
......
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