aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-21 02:03:56 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-21 02:03:56 +0200
commitb9573a485baf98e9fb749289b8b9c1f73f70d280 (patch)
tree55f0a98a827a071860ebe4400f20beca34cf4c0c
parent1c35b863b47b558a1b2e7f2f4673643b4f0128d4 (diff)
downloadEpisodeBrowser-b9573a485baf98e9fb749289b8b9c1f73f70d280.tar.gz
Fix memory bug.
-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