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

This commit is contained in:
Christian Faure 2015-05-16 16:52:18 +03:00 committed by Alexandre Julliard
parent 2e21381177
commit 9cffed782f
2 changed files with 23 additions and 0 deletions

View File

@ -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)
{

View File

@ -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++)