image-rs / jpeg-decoder

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

Fix bogus check for icc markers #204

Closed vstroebel closed 2 years ago

vstroebel commented 2 years ago

This don't change anything in the behavior, because 0 is always <256 and the >=256 case is always true in the first condition of the loop below (256 is always larger than what chunk.num_markers: u8 can represent).

It would be better to emit a warning in case of invalid ICC profile data but the encoder currently lacks a way to do this...

vstroebel commented 2 years ago

Good find! Do you happen to have a reproduction/regression test that is usable (from a license perspective)?

Because the original code doesn't result in any real bug there isn't any reproducible test possible. But I've added some tests that check certain aspects of chunk handling.

The test images contain only a black pixel with some fake ICC data.

HeroicKatora commented 2 years ago

Perfect, that works very well. Thank you!