make sure we use BigEndian when reading numbers via StreamingReader (#2821)

This commit is contained in:
Antioch Peverell 2019-05-13 23:04:14 +01:00 committed by Ignotus Peverell
parent 59db5e3bd1
commit 4ba7b0a46a

View file

@ -393,32 +393,32 @@ impl<'a> StreamingReader<'a> {
impl<'a> Reader for StreamingReader<'a> { impl<'a> Reader for StreamingReader<'a> {
fn read_u8(&mut self) -> Result<u8, Error> { fn read_u8(&mut self) -> Result<u8, Error> {
let buf = self.read_fixed_bytes(1)?; let buf = self.read_fixed_bytes(1)?;
deserialize(&mut &buf[..]) Ok(buf[0])
} }
fn read_u16(&mut self) -> Result<u16, Error> { fn read_u16(&mut self) -> Result<u16, Error> {
let buf = self.read_fixed_bytes(2)?; let buf = self.read_fixed_bytes(2)?;
deserialize(&mut &buf[..]) Ok(BigEndian::read_u16(&buf[..]))
} }
fn read_u32(&mut self) -> Result<u32, Error> { fn read_u32(&mut self) -> Result<u32, Error> {
let buf = self.read_fixed_bytes(4)?; let buf = self.read_fixed_bytes(4)?;
deserialize(&mut &buf[..]) Ok(BigEndian::read_u32(&buf[..]))
} }
fn read_i32(&mut self) -> Result<i32, Error> { fn read_i32(&mut self) -> Result<i32, Error> {
let buf = self.read_fixed_bytes(4)?; let buf = self.read_fixed_bytes(4)?;
deserialize(&mut &buf[..]) Ok(BigEndian::read_i32(&buf[..]))
} }
fn read_u64(&mut self) -> Result<u64, Error> { fn read_u64(&mut self) -> Result<u64, Error> {
let buf = self.read_fixed_bytes(8)?; let buf = self.read_fixed_bytes(8)?;
deserialize(&mut &buf[..]) Ok(BigEndian::read_u64(&buf[..]))
} }
fn read_i64(&mut self) -> Result<i64, Error> { fn read_i64(&mut self) -> Result<i64, Error> {
let buf = self.read_fixed_bytes(8)?; let buf = self.read_fixed_bytes(8)?;
deserialize(&mut &buf[..]) Ok(BigEndian::read_i64(&buf[..]))
} }
/// Read a variable size vector from the underlying stream. Expects a usize /// Read a variable size vector from the underlying stream. Expects a usize