Skip to content

Commit

Permalink
Fix GifDecoder::with_limits to raise an error when limits are excee…
Browse files Browse the repository at this point in the history
…ded (#2083)
  • Loading branch information
Shnatsel authored Jan 4, 2024
1 parent 25b284c commit 1dd2079
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/codecs/gif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ impl<R: Read> GifDecoder<R> {
}

/// Creates a new decoder that decodes the input steam `r`, using limits `limits`
#[deprecated(since = "0.24.8", note = "Use `new` followed by `set_limits` instead")]
pub fn with_limits(r: R, limits: Limits) -> ImageResult<GifDecoder<R>> {
let mut decoder = gif::DecodeOptions::new();
decoder.set_color_output(ColorOutput::RGBA);

Ok(GifDecoder {
reader: decoder.read_info(r).map_err(ImageError::from_decoding)?,
limits,
})
let mut decoder = Self::new(r)?;
// call `.set_limits()` instead of just setting the field directly
// so that we raise an error in case they are exceeded
decoder.set_limits(limits)?;
Ok(decoder)
}
}

Expand Down

0 comments on commit 1dd2079

Please sign in to comment.