From 15dcd6ad15cf40bf51ed234bb73f06c475240dda Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 28 Apr 2023 20:00:14 +0200 Subject: [PATCH] libluna: Check the whole string in Utf8StringDecoder::code_points() --- libluna/src/Utf8.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libluna/src/Utf8.cpp b/libluna/src/Utf8.cpp index 1a175b68..0a4873e3 100644 --- a/libluna/src/Utf8.cpp +++ b/libluna/src/Utf8.cpp @@ -138,9 +138,9 @@ Result Utf8StringDecoder::code_points() const while ((usize)(it - m_str) < m_byte_length) { - const usize utf8_len = TRY(utf8_char_length(*it)); - if ((usize)(it - m_str) + utf8_len > m_byte_length) return err(EILSEQ); - it += utf8_len; + usize mb_len = m_byte_length - (usize)(it - m_str); // Remaining space + TRY(encode_utf8_as_wide_char(it, mb_len)); + it += mb_len; len++; }