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

DecompressorWriter sometimes panics on drop if the input is invalid brotli #21

Closed
jyn514 opened this issue Dec 7, 2022 · 1 comment
Closed

Comments

@jyn514
Copy link

jyn514 commented Dec 7, 2022

This is similar to #13, but not caused by a misuse of the API, it can happen whenever the input is invalid.

The only times it doesn't happen is when the error isn't reported at all (#20).

; cat examples/compress.rs 
use std::io::{self, Write};

fn main() {
    let compressed = b"xxxxxxxxxxx";
    if let Err(e) = brotli_decompressor::writer::DecompressorWriter::new(io::stdout(), 1024).write(compressed) {
        eprintln!("{}", e);
    }
}
; cargo run --example compress -q; echo $?
Invalid Data
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/jnelson/work/rust-brotli-decompressor/src/writer.rs:260:88
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
101
jongiddy added a commit to jongiddy/rust-brotli-decompressor that referenced this issue Dec 8, 2022
Dropping a `DecompressorWriterCustomIo` needs to call a version of
`close` that does not take the `error_if_invalid_data` object.  At drop
time, this object may already have been taken in the `write` call.

Fixes dropbox#21
@danielrh
Copy link
Collaborator

Thanks for the report! Fixed in 092aa00

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

Successfully merging a pull request may close this issue.

2 participants