add missing self.pos to peek_char slices (#1726)
This commit is contained in:
@@ -187,7 +187,7 @@ impl<R: Read> CharRead for CharReader<R> {
|
||||
if self.pos >= self.buf.len() {
|
||||
return None;
|
||||
} else if self.buf.len() - self.pos >= 4 {
|
||||
return match str::from_utf8(&self.buf[..e.valid_up_to()]) {
|
||||
return match str::from_utf8(&self.buf[self.pos .. e.valid_up_to()]) {
|
||||
Ok(s) => {
|
||||
let mut chars = s.chars();
|
||||
let c = chars.next().unwrap();
|
||||
@@ -195,7 +195,7 @@ impl<R: Read> CharRead for CharReader<R> {
|
||||
Some(Ok(c))
|
||||
}
|
||||
Err(e) => {
|
||||
let badbytes = self.buf[..e.valid_up_to()].to_vec();
|
||||
let badbytes = self.buf[self.pos .. e.valid_up_to()].to_vec();
|
||||
|
||||
Some(Err(io::Error::new(io::ErrorKind::InvalidData,
|
||||
BadUtf8Error { bytes: badbytes })))
|
||||
|
||||
Reference in New Issue
Block a user