Commit fdffe548 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added space for nullbyte in size returned by wcstombs_s and mbstowcs_s.

parent f54b1688
...@@ -1900,7 +1900,7 @@ int CDECL MSVCRT__mbstowcs_s_l(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr, ...@@ -1900,7 +1900,7 @@ int CDECL MSVCRT__mbstowcs_s_l(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr,
if(!wcstr && !size) { if(!wcstr && !size) {
conv = MSVCRT__mbstowcs_l(NULL, mbstr, 0, locale); conv = MSVCRT__mbstowcs_l(NULL, mbstr, 0, locale);
if(ret) if(ret)
*ret = conv; *ret = conv+1;
return 0; return 0;
} }
......
...@@ -1337,6 +1337,10 @@ static void test_mbstowcs(void) ...@@ -1337,6 +1337,10 @@ static void test_mbstowcs(void)
ok(ret == 3, "ret = %d\n", (int)ret); ok(ret == 3, "ret = %d\n", (int)ret);
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut)); ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
ok(err == 0, "err = %d\n", err);
ok(ret == 3, "ret = %d\n", (int)ret);
err = pwcstombs_s(&ret, mOut, 6, wSimple, _TRUNCATE); err = pwcstombs_s(&ret, mOut, 6, wSimple, _TRUNCATE);
ok(err == 0, "err = %d\n", err); ok(err == 0, "err = %d\n", err);
ok(ret == 5, "ret = %d\n", (int)ret); ok(ret == 5, "ret = %d\n", (int)ret);
...@@ -1346,6 +1350,10 @@ static void test_mbstowcs(void) ...@@ -1346,6 +1350,10 @@ static void test_mbstowcs(void)
ok(err == 0, "err = %d\n", err); ok(err == 0, "err = %d\n", err);
ok(ret == 5, "ret = %d\n", (int)ret); ok(ret == 5, "ret = %d\n", (int)ret);
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut); ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
ok(err == 0, "err = %d\n", err);
ok(ret == 5, "ret = %d\n", (int)ret);
} }
static void test_gcvt(void) static void test_gcvt(void)
......
...@@ -341,7 +341,7 @@ MSVCRT_size_t CDECL MSVCRT__wcstombs_s_l(MSVCRT_size_t *ret, char *mbstr, ...@@ -341,7 +341,7 @@ MSVCRT_size_t CDECL MSVCRT__wcstombs_s_l(MSVCRT_size_t *ret, char *mbstr,
if(!mbstr && !size) { if(!mbstr && !size) {
conv = MSVCRT__wcstombs_l(NULL, wcstr, 0, locale); conv = MSVCRT__wcstombs_l(NULL, wcstr, 0, locale);
if(ret) if(ret)
*ret = conv; *ret = conv+1;
return 0; return 0;
} }
......
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