aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-core/src
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2022-10-13 18:21:33 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2022-10-13 18:22:10 +0200
commit385258b6e72414869796e56b38f1d11776ef150c (patch)
treefec2d44af58ef71b195e3ba9d29e2385a0ac451b /nihav-core/src
parent6048a37fc8d7f639b59be33027d0eadb09b1a7b7 (diff)
downloadnihav-385258b6e72414869796e56b38f1d11776ef150c.tar.gz
core/io: allow skipping right to the bitstream end
Diffstat (limited to 'nihav-core/src')
-rw-r--r--nihav-core/src/io/bitreader.rs5
1 files changed, 4 insertions, 1 deletions
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(())