xmllite/writer: Null terminate duplicated strings.

Strings are not being "partially duplicated", but duplicated
with explicit length.

Signed-off-by: David Kahurani <k.kahurani@gmail.com>
This commit is contained in:
David Kahurani 2022-10-10 16:01:23 +03:00 committed by Alexandre Julliard
parent e3f00bf7c9
commit 556b3981b7

View file

@ -250,7 +250,6 @@ static struct element *pop_element(xmlwriter *writer)
static WCHAR *writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len)
{
size_t size;
WCHAR *ret;
if (!str)
@ -259,9 +258,12 @@ static WCHAR *writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len
if (len == -1)
len = lstrlenW(str);
size = (len + 1) * sizeof(WCHAR);
ret = writer_alloc(writer, size);
if (ret) memcpy(ret, str, size);
ret = writer_alloc(writer, (len + 1) * sizeof(WCHAR));
if (ret)
{
memcpy(ret, str, len * sizeof(WCHAR));
ret[len] = 0;
}
return ret;
}