David Kahurani : xmllite/writer: Null terminate duplicated strings.
Module: wine Branch: master Commit: 556b3981b7aab37dcc184ff8c4682f5d079f8be9 URL: https://gitlab.winehq.org/wine/wine/-/commit/556b3981b7aab37dcc184ff8c4682f5... Author: David Kahurani <k.kahurani(a)gmail.com> Date: Mon Oct 10 16:01:23 2022 +0300 xmllite/writer: Null terminate duplicated strings. Strings are not being "partially duplicated", but duplicated with explicit length. Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> --- dlls/xmllite/writer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index c4f9ed2f440..065716f7e8c 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -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; }
participants (1)
-
Alexandre Julliard