Commit 544d1794 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Handle null mbstr parameter in mbstowcs.

parent ec8e5c61
......@@ -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
......
......@@ -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");
......
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