aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/data.cpp2
1 files changed, 1 insertions, 1 deletions
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 <size_t N>
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<size_t>(lenUtf8))] = 0;
/* Convert internal representation from UTF-8 to Latin-1,
* which seems to actually convert the string to proper UTF-8