Commit 9cffed78 authored by Christian Faure's avatar Christian Faure Committed by Alexandre Julliard

kernel32: Fix a crash in GetStringTypeW() on NULL input string.

parent 2e213811
......@@ -2732,6 +2732,12 @@ BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype
C2_OTHERNEUTRAL /* LRE, LRO, RLE, RLO, PDF */
};
if (!src)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (count == -1) count = strlenW(src) + 1;
switch(type)
{
......
......@@ -3582,9 +3582,26 @@ static void test_GetStringTypeW(void)
static const WCHAR space_special[] = {0x09, 0x0d, 0x85};
WORD types[20];
BOOL ret;
WCHAR ch;
int i;
/* NULL src */
SetLastError(0xdeadbeef);
ret = GetStringTypeW(CT_CTYPE1, NULL, 0, NULL);
ok(!ret, "got %d\n", ret);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = GetStringTypeW(CT_CTYPE1, NULL, 0, types);
ok(!ret, "got %d\n", ret);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = GetStringTypeW(CT_CTYPE1, NULL, 5, types);
ok(!ret, "got %d\n", ret);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
memset(types,0,sizeof(types));
GetStringTypeW(CT_CTYPE1, blanks, 5, types);
for (i = 0; i < 5; i++)
......
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