From e796aba9287397f554ce034130b3ae8ec67df451 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 27 Jul 2014 01:30:14 -0700 Subject: [PATCH] Set proper output length for string conversions --- libobs/util/platform.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libobs/util/platform.c b/libobs/util/platform.c index 1041861d6..af4a19a52 100644 --- a/libobs/util/platform.c +++ b/libobs/util/platform.c @@ -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; }