From dda97dbccb0666f3d576ac26f9c65d68e186cbb7 Mon Sep 17 00:00:00 2001 From: EmperorBale Date: Fri, 15 Jul 2022 14:18:38 -0700 Subject: [PATCH] wstr: Fix small logic error when decoding UTF-8 --- wstr/src/utils.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wstr/src/utils.rs b/wstr/src/utils.rs index 80eae3bdb..ac9d9af1d 100644 --- a/wstr/src/utils.rs +++ b/wstr/src/utils.rs @@ -155,11 +155,13 @@ impl<'a> Iterator for AvmUtf8Decoder<'a> { ch <<= 6; ch |= (*b & (u8::MAX >> 2)) as u32; } - if ch <= 128 { - self.index += 1; - ch = first as u32; - } else if !fail { - self.index += mb_count as usize + 1; + if !fail { + if ch <= 128 { + self.index += 1; + ch = first as u32; + } else { + self.index += mb_count as usize + 1; + } } } None => {