0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

Set proper output length for string conversions

This commit is contained in:
jp9000 2014-07-27 01:30:14 -07:00
parent 99d8bdcee7
commit e796aba928

View File

@ -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;
}