libluna: Check the whole string in Utf8StringDecoder::code_points()

This commit is contained in:
apio 2023-04-28 20:00:14 +02:00
parent b4a5aff071
commit 15dcd6ad15
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -138,9 +138,9 @@ Result<usize> Utf8StringDecoder::code_points() const
while ((usize)(it - m_str) < m_byte_length) while ((usize)(it - m_str) < m_byte_length)
{ {
const usize utf8_len = TRY(utf8_char_length(*it)); usize mb_len = m_byte_length - (usize)(it - m_str); // Remaining space
if ((usize)(it - m_str) + utf8_len > m_byte_length) return err(EILSEQ); TRY(encode_utf8_as_wide_char(it, mb_len));
it += utf8_len; it += mb_len;
len++; len++;
} }