From 0055aa67f155d1f50b7b6c647e909b436289f807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Fri, 1 Feb 2019 09:42:51 +0100 Subject: [PATCH] vkd3d-common: Fix vkd3d_strdup_{w16, w32}_utf8() functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-common/utf8.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d-common/utf8.c b/libs/vkd3d-common/utf8.c index e48316da..8bf4eb05 100644 --- a/libs/vkd3d-common/utf8.c +++ b/libs/vkd3d-common/utf8.c @@ -107,8 +107,8 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr) { const uint16_t *src = wstr; size_t dst_size = 0; + char *dst, *utf8; uint32_t c; - char *dst; while (*src) { @@ -121,14 +121,15 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr) if (!(dst = vkd3d_malloc(dst_size))) return NULL; + utf8 = dst; src = wstr; while (*src) { if (!(c = vkd3d_utf16_read(&src))) continue; - vkd3d_utf8_append(&dst, c); + vkd3d_utf8_append(&utf8, c); } - *dst = 0; + *utf8 = 0; return dst; } @@ -137,7 +138,7 @@ static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr) { const uint32_t *src = wstr; size_t dst_size = 0; - char *dst; + char *dst, *utf8; while (*src) dst_size += vkd3d_utf8_len(*src++); @@ -146,10 +147,11 @@ static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr) if (!(dst = vkd3d_malloc(dst_size))) return NULL; + utf8 = dst; src = wstr; while (*src) - vkd3d_utf8_append(&dst, *src++); - *dst = 0; + vkd3d_utf8_append(&utf8, *src++); + *utf8 = 0; return dst; }