vkd3d-common: Fix vkd3d_strdup_{w16, w32}_utf8() functions.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-02-01 09:42:51 +01:00 committed by Alexandre Julliard
parent 6a3c75d0d1
commit 0055aa67f1

View File

@ -107,8 +107,8 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
{ {
const uint16_t *src = wstr; const uint16_t *src = wstr;
size_t dst_size = 0; size_t dst_size = 0;
char *dst, *utf8;
uint32_t c; uint32_t c;
char *dst;
while (*src) while (*src)
{ {
@ -121,14 +121,15 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
if (!(dst = vkd3d_malloc(dst_size))) if (!(dst = vkd3d_malloc(dst_size)))
return NULL; return NULL;
utf8 = dst;
src = wstr; src = wstr;
while (*src) while (*src)
{ {
if (!(c = vkd3d_utf16_read(&src))) if (!(c = vkd3d_utf16_read(&src)))
continue; continue;
vkd3d_utf8_append(&dst, c); vkd3d_utf8_append(&utf8, c);
} }
*dst = 0; *utf8 = 0;
return dst; return dst;
} }
@ -137,7 +138,7 @@ static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr)
{ {
const uint32_t *src = wstr; const uint32_t *src = wstr;
size_t dst_size = 0; size_t dst_size = 0;
char *dst; char *dst, *utf8;
while (*src) while (*src)
dst_size += vkd3d_utf8_len(*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))) if (!(dst = vkd3d_malloc(dst_size)))
return NULL; return NULL;
utf8 = dst;
src = wstr; src = wstr;
while (*src) while (*src)
vkd3d_utf8_append(&dst, *src++); vkd3d_utf8_append(&utf8, *src++);
*dst = 0; *utf8 = 0;
return dst; return dst;
} }