Commit 967fb744 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

msvcrt: Fix mbstowcs with empty strings.

parent 82bf4edf
......@@ -2278,12 +2278,14 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
size += (MSVCRT__isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
}
size = MultiByteToWideChar(locinfo->lc_codepage, 0,
mbstr, size, wcstr, count);
if(!size) {
if(count) wcstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_EILSEQ;
return -1;
if(size) {
size = MultiByteToWideChar(locinfo->lc_codepage, 0,
mbstr, size, wcstr, count);
if(!size) {
if(count) wcstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_EILSEQ;
return -1;
}
}
if(size<count && wcstr)
......
......@@ -1900,7 +1900,7 @@ static void test_mbstowcs(void)
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
ret = mbstowcs(wOut, mEmpty, 6);
todo_wine ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
ret = wcstombs(mOut, wHiragana, 6);
......@@ -1928,8 +1928,8 @@ static void test_mbstowcs(void)
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
err = pmbstowcs_s(&ret, wOut, 6, mEmpty, _TRUNCATE);
todo_wine ok(err == 0, "err = %d\n", err);
todo_wine ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
ok(err == 0, "err = %d\n", err);
ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
......
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