Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BzEncoder::new with Compression::none fails with -2 #107

Open
igankevich opened this issue Nov 12, 2024 · 0 comments
Open

BzEncoder::new with Compression::none fails with -2 #107

igankevich opened this issue Nov 12, 2024 · 0 comments

Comments

@igankevich
Copy link

While I was fuzzying my project I noticed that BzEncoder does not accept Compression::none(), although the documentation mentions 0 as a valid value.

Here is the code to reproduce the error.

use bzip2::write::BzEncoder;
use bzip2::Compression;

fn main() {
    let mut _encoder = BzEncoder::new(Vec::new(), Compression::none());
}

And here is the output.

thread 'main' panicked at /src/index.crates.io-6f17d22bba15001f/bzip2-0.4.4/src/mem.rs:123:13:
assertion `left == right` failed
  left: -2
 right: 0
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /tmp/guix-build-rust-1.80.0.drv-0/rustc-1.80.0-src/library/core/src/panicking.rs:363:5
   4: bzip2::mem::Compress::new
             at /src/index.crates.io-6f17d22bba15001f/bzip2-0.4.4/src/mem.rs:123:13
   5: bzip2::write::BzEncoder<W>::new
             at /src/index.crates.io-6f17d22bba15001f/bzip2-0.4.4/src/write.rs:36:19
   6: bzip_test::main
             at ./src/main.rs:5:24
   7: core::ops::function::FnOnce::call_once
             at /tmp/guix-build-rust-1.80.0.drv-0/rustc-1.80.0-src/library/core/src/ops/function.rs:250:5

So, either the documentation or the code is wrong 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant