image-rs / jpeg-decoder

JPEG decoder written in Rust
Apache License 2.0
149 stars 87 forks source link

panic only when release #194

Open Athlon64 opened 3 years ago

Athlon64 commented 3 years ago

I was just trying this crate with the simple example on the main webpage. When running it with cargo run, everything was perfect as expected. But when I ran it with cargo run --release, it panicked:

thread 'main' panicked at 'failed to open file: Decoding(DecodingError { format: Exact(Jpeg), underlying: Some(Format("invalid length in DHT")) })', src/main.rs:12:35

and I tried a lot of different jpgs, always the same result.

I am wondering is this a bug or something?

fintelia commented 3 years ago

Sounds like a bug. Are you able to provide an example image and a code snippet that causes the crash?

Athlon64 commented 3 years ago

Thanks for replying.

The code snippet is as follows:

extern crate jpeg_decoder as jpeg;

use std::fs::File;
use std::io::BufReader;

fn main() {
    let file = File::open("test.jpg").expect("failed to open file");
    let mut decoder = jpeg::Decoder::new(BufReader::new(file));
    let pixels = decoder.decode().expect("failed to decode image");
    let metadata = decoder.info().unwrap();
}

I just copied the example and changed the name of the image to mine. The image was downloaded from the Internet and attached below.

test

P.S. My OS is Archlinux, rust compiler version is 1.54.0

fintelia commented 3 years ago

Hm, I was unable to replicate this on Ubuntu or Arch