Skip to content

Commit c78469e

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)