Set proper output length for string conversions
This commit is contained in:
@@ -249,7 +249,7 @@ size_t os_mbs_to_wcs(const char *str, size_t len, wchar_t *dst, size_t dst_size)
|
||||
return 0;
|
||||
|
||||
if (out_len)
|
||||
mbstowcs(dst, str, out_len + 1);
|
||||
out_len = mbstowcs(dst, str, out_len + 1);
|
||||
|
||||
dst[out_len] = 0;
|
||||
}
|
||||
@@ -274,7 +274,8 @@ size_t os_utf8_to_wcs(const char *str, size_t len, wchar_t *dst,
|
||||
return 0;
|
||||
|
||||
if (out_len)
|
||||
utf8_to_wchar(str, in_len, dst, out_len + 1, 0);
|
||||
out_len = utf8_to_wchar(str, in_len,
|
||||
dst, out_len + 1, 0);
|
||||
|
||||
dst[out_len] = 0;
|
||||
}
|
||||
@@ -296,7 +297,7 @@ size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char *dst, size_t dst_size)
|
||||
return 0;
|
||||
|
||||
if (out_len)
|
||||
wcstombs(dst, str, out_len + 1);
|
||||
out_len = wcstombs(dst, str, out_len + 1);
|
||||
|
||||
dst[out_len] = 0;
|
||||
}
|
||||
@@ -321,7 +322,8 @@ size_t os_wcs_to_utf8(const wchar_t *str, size_t len, char *dst,
|
||||
return 0;
|
||||
|
||||
if (out_len)
|
||||
wchar_to_utf8(str, in_len, dst, out_len + 1, 0);
|
||||
out_len = wchar_to_utf8(str, in_len,
|
||||
dst, out_len + 1, 0);
|
||||
|
||||
dst[out_len] = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user