We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b65f1ec commit 48168d0Copy full SHA for 48168d0
portable/src/implementation/fallback.rs
@@ -70,19 +70,15 @@ impl Utf8ValidatorImp {
70
}
71
};
72
let rem_input = input.len() - e.valid_up_to() - 1;
73
- if rem_input >= self.expected_cont_bytes as usize {
74
- // too many continuation bytes so they are not valid
75
- self.err = true;
76
- return;
77
- }
78
- for i in 0..rem_input {
+ for i in 0..rem_input.min(self.expected_cont_bytes as usize) {
79
if input[e.valid_up_to() + i + 1] & 0b1100_0000 != 0b1000_0000 {
80
// not a continuation byte
81
self.err = true;
82
return;
83
84
self.expected_cont_bytes -= 1;
85
+ debug_assert!(self.expected_cont_bytes != 0); // otherwise from_utf8 would not have errored
86
87
88
0 commit comments