msvcrt: Handle null mbstr parameter in mbstowcs.

This commit is contained in:
Piotr Caban 2014-01-08 12:13:22 +01:00 committed by Alexandre Julliard
parent ec8e5c610b
commit 544d179434
2 changed files with 10 additions and 0 deletions

View File

@ -2127,6 +2127,11 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
MSVCRT_pthreadlocinfo locinfo;
MSVCRT_size_t i, size;
if(!mbstr) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
if(!locale)
locinfo = get_locinfo();
else

View File

@ -1635,6 +1635,11 @@ static void test_mbstowcs(void)
wOut[4] = '!'; wOut[5] = '\0';
mOut[4] = '!'; mOut[5] = '\0';
errno = 0xdeadbeef;
ret = mbstowcs(wOut, NULL, 4);
ok(ret == -1, "mbstowcs did not return -1\n");
ok(errno == EINVAL, "errno = %d\n", errno);
ret = mbstowcs(NULL, mSimple, 0);
ok(ret == 4, "mbstowcs did not return 4\n");