From c206b7cce8c2d64e6da4dc33c68aab604f7eb87e Mon Sep 17 00:00:00 2001 From: ephphatha Date: Sun, 21 Nov 2021 22:58:21 +1100 Subject: [PATCH] Return Utf8DecodeError when passed an incomplete code point Also ensure that len set in all code paths, otherwise it leads to a call to remove_prefix with garbage. --- Source/utils/utf8.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/utils/utf8.cpp b/Source/utils/utf8.cpp index a1c117865..bc439978c 100644 --- a/Source/utils/utf8.cpp +++ b/Source/utils/utf8.cpp @@ -21,7 +21,8 @@ char32_t DecodeFirstUtf8CodePoint(string_view input, uint8_t *len) return Utf8DecodeError; } } - return codepoint; + *len = input.size(); + return Utf8DecodeError; } } // namespace devilution