Fix use of byte count instead of char count.
This commit is contained in:
parent
e925308e82
commit
e6c4d042e4
2 changed files with 14 additions and 2 deletions
|
@ -1775,8 +1775,9 @@ impl<T: Input> Scanner<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to manually update our position; we haven't called a `skip` function.
|
// We need to manually update our position; we haven't called a `skip` function.
|
||||||
self.mark.col += line_buffer.len();
|
let n_chars = line_buffer.chars().count();
|
||||||
self.mark.index += line_buffer.len();
|
self.mark.col += n_chars;
|
||||||
|
self.mark.index += n_chars;
|
||||||
|
|
||||||
// We can now append our bytes to our `string`.
|
// We can now append our bytes to our `string`.
|
||||||
string.reserve(line_buffer.as_bytes().len());
|
string.reserve(line_buffer.as_bytes().len());
|
||||||
|
|
|
@ -74,3 +74,14 @@ fn fuzz_2() {
|
||||||
let s = str::from_utf8(raw_input).unwrap();
|
let s = str::from_utf8(raw_input).unwrap();
|
||||||
let _ = run_parser(s);
|
let _ = run_parser(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fuzz_3() {
|
||||||
|
// Span mismatch when parsing with `StrInput` and `BufferedInput`.
|
||||||
|
// In block scalars, there was a section in which we took the byte count rather than the char
|
||||||
|
// count to update the index. The issue didn't happen with `StrInput` as the buffer was always
|
||||||
|
// full and the offending code was never executed.
|
||||||
|
let raw_input: &[u8] = &[124, 13, 32, 210, 180, 65];
|
||||||
|
let s = str::from_utf8(raw_input).unwrap();
|
||||||
|
let _ = run_parser(s);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue