From b9573a485baf98e9fb749289b8b9c1f73f70d280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 21 Aug 2022 02:03:56 +0200 Subject: Fix memory bug. --- c/data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'c') diff --git a/c/data.cpp b/c/data.cpp index c2a8909..0e747f1 100644 --- a/c/data.cpp +++ b/c/data.cpp @@ -72,8 +72,8 @@ template bool WcharsFromXmlchars(wchar_t (&dst)[N], XmlCharPtr utf8) { /* Truncate if source is larger than destination. */ - utf8[N] = 0; int lenUtf8 = xmlStrlen(utf8); + utf8[std::min(N, static_cast(lenUtf8))] = 0; /* Convert internal representation from UTF-8 to Latin-1, * which seems to actually convert the string to proper UTF-8 -- cgit v1.2.3