Skip to content

Commit

Permalink
reader: Fix bug in new reader implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Feb 22, 2020
1 parent f2331b4 commit f7d55af
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl VarIntProcessor {
(self.i > 0 && (self.buf[self.i - 1] & MSB == 0))
}
fn decode<VI: VarInt>(&self) -> VI {
VI::decode_var(&self.buf[0..self.i]).0
VI::decode_var(&self.buf[0..self.i+1]).0
}
}

Expand All @@ -67,7 +67,9 @@ impl<AR: AsyncRead + Unpin + Send> VarIntAsyncReader for AR {
return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "Reached EOF"));
}

p.push(buf[0])?;
if read != 0 {
p.push(buf[0])?;
}
}

Ok(p.decode())
Expand All @@ -87,7 +89,9 @@ impl<R: Read> VarIntReader for R {
return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "Reached EOF"));
}

p.push(buf[0])?;
if read != 0 {
p.push(buf[0])?;
}
}

Ok(p.decode())
Expand Down

0 comments on commit f7d55af

Please sign in to comment.