From 1dd207907412e28896e639c631e3f6b8b7a04934 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Thu, 4 Jan 2024 00:55:09 +0000 Subject: [PATCH] Fix `GifDecoder::with_limits` to raise an error when limits are exceeded (#2083) --- src/codecs/gif.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/codecs/gif.rs b/src/codecs/gif.rs index ae0b98e7eb..a5e52fa095 100644 --- a/src/codecs/gif.rs +++ b/src/codecs/gif.rs @@ -65,14 +65,13 @@ impl GifDecoder { } /// 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> { - 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) } }