From: Kostya Shishkov Date: Thu, 13 Oct 2022 16:21:33 +0000 (+0200) Subject: core/io: allow skipping right to the bitstream end X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;ds=sidebyside;h=385258b6e72414869796e56b38f1d11776ef150c;p=nihav.git core/io: allow skipping right to the bitstream end --- diff --git a/nihav-core/src/io/bitreader.rs b/nihav-core/src/io/bitreader.rs index 569330b..c4f9f6c 100644 --- a/nihav-core/src/io/bitreader.rs +++ b/nihav-core/src/io/bitreader.rs @@ -305,8 +305,11 @@ impl<'a> BitReader<'a> { self.reset_cache(); self.pos += ((skip_bits / 32) * 4) as usize; skip_bits &= 0x1F; - self.refill()?; if skip_bits > 0 { + self.refill()?; + if u32::from(self.bits) < skip_bits { + return Err(BitstreamEnd); + } self.skip_cache(skip_bits as u8); } Ok(())