Skip to content

Commit

Permalink
Disable strict mode for JPEG decoder (#2183)
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored Mar 26, 2024
1 parent 73c7bfe commit 5c3d3db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/codecs/jpeg/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl<R: BufRead + Seek> JpegDecoder<R> {
let mut r = r;
r.read_to_end(&mut input)?;
let options = zune_core::options::DecoderOptions::default()
.set_strict_mode(false)
.set_max_width(usize::MAX)
.set_max_height(usize::MAX);
let mut decoder = zune_jpeg::JpegDecoder::new_with_options(input.as_slice(), options);
Expand Down Expand Up @@ -133,8 +134,9 @@ fn new_zune_decoder(
limits: Limits,
) -> zune_jpeg::JpegDecoder<&[u8]> {
let target_color_space = to_supported_color_space(orig_color_space);
let mut options =
zune_core::options::DecoderOptions::default().jpeg_set_out_colorspace(target_color_space);
let mut options = zune_core::options::DecoderOptions::default()
.jpeg_set_out_colorspace(target_color_space)
.set_strict_mode(false);
options = options.set_max_width(match limits.max_image_width {
Some(max_width) => max_width as usize, // u32 to usize never truncates
None => usize::MAX,
Expand Down

0 comments on commit 5c3d3db

Please sign in to comment.