From 76f01d8c9fea275840391f07c9c2cd95ac9800fb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 6 Aug 2026 00:00:38 +1000 Subject: [PATCH] Misc: Fix under-allocation in sjis2utf8() This whole thing needs to be tossed and rewritten. --- src/util/shiftjis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/shiftjis.cpp b/src/util/shiftjis.cpp index 1d66c1e3a..9239db67f 100644 --- a/src/util/shiftjis.cpp +++ b/src/util/shiftjis.cpp @@ -1540,7 +1540,7 @@ char* sjis2utf8(char* input) size_t len = static_cast(std::strlen(input)); char* output = reinterpret_cast( - std::malloc(3 * len)); // ShiftJis won't give 4byte UTF8, so max. 3 byte per input char are needed + std::malloc(3 * len + 1)); // ShiftJis won't give 4byte UTF8, so max. 3 byte per input char are needed size_t indexInput = 0, indexOutput = 0; while (indexInput < len)