Skip to content

Commit

Permalink
png/decoder: Don't panic on overflow in calculation and inform the user.
Browse files Browse the repository at this point in the history
Fixes the remaining crashes in #221
  • Loading branch information
etemesi254 committed Jul 27, 2024
1 parent ee1c2b8 commit 7fee844
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/zune-png/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ impl<T: ZByteReaderTrait> PngDecoder<T> {

let png_info = self.png_info.clone();

let image_len = self.inner_buffer_size().unwrap();
let image_len = self.inner_buffer_size()
.ok_or(PngDecodeErrors::GenericStatic("Output buffer size overflowed a usize (corrupt png?)"))?;

if out.len() < image_len {
return Err(PngDecodeErrors::TooSmallOutput(image_len, out.len()));
Expand Down

0 comments on commit 7fee844

Please sign in to comment.