Sign extend negative `s24` values correctly.

This commit is contained in:
David Wendt 2020-03-05 19:42:44 -05:00
parent 7253c091a2
commit a44e700e81
1 changed files with 3 additions and 3 deletions

View File

@ -102,9 +102,9 @@ impl<R: Read> Reader<R> {
#[allow(dead_code)] #[allow(dead_code)]
fn read_i24(&mut self) -> Result<i32> { fn read_i24(&mut self) -> Result<i32> {
Ok(i32::from(self.read_u8()?) Ok(i32::from(self.read_u8()? as i8)
| (i32::from(self.read_u8()?) << 8) | (i32::from(self.read_u8()? as i8) << 8)
| (i32::from(self.read_u8()?) << 16)) | (i32::from(self.read_u8()? as i8) << 16))
} }
fn read_i32(&mut self) -> Result<i32> { fn read_i32(&mut self) -> Result<i32> {
let mut n: i32 = 0; let mut n: i32 = 0;