Skip to content

Commit 6dd666f

Browse files
committed
debug assert that we don't read more input too often
1 parent 0a58925 commit 6dd666f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

libbz2-rs-sys/src/blocksort.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![forbid(unsafe_code)]
2+
#![deny(clippy::cast_lossless)]
23

34
use core::cmp::Ordering;
45
use core::ffi::{c_int, c_uint};

libbz2-rs-sys/src/bzlib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ mod stream {
254254
mut bit_buffer: u64,
255255
bits_used: i32,
256256
) -> Option<(u64, i32)> {
257+
// we should only ask for more input if there are at least 8 free bits
258+
debug_assert!(bits_used <= 56);
259+
257260
if self.avail_in < 8 {
258261
return None;
259262
}
@@ -289,6 +292,9 @@ mod stream {
289292
mut bit_buffer: u64,
290293
bits_used: i32,
291294
) -> Option<(u64, i32)> {
295+
// we should only ask for more input if there are at least 8 free bits
296+
debug_assert!(bits_used <= 56);
297+
292298
if self.avail_in == 0 || bits_used > 56 {
293299
return None;
294300
}

0 commit comments

Comments
 (0)