diff --git a/src/decoders/mod.rs b/src/decoders/mod.rs index cf75195..2a1df03 100644 --- a/src/decoders/mod.rs +++ b/src/decoders/mod.rs @@ -24,8 +24,9 @@ macro_rules! fetch_ifd { macro_rules! alloc_image_plain { ($width:expr, $height:expr, $dummy: expr) => ( { - if $width * $height > 500000000 || $width > 50000 || $height > 50000 { - panic!("rawloader: surely there's no such thing as a >500MP or >50000 px wide/tall image!"); + let pixels = ($width as u64).checked_mul($height as u64).unwrap_or(u64::MAX); + if pixels > 500000000 || $width > 50000 || $height > 50000 { + panic!("rawloader: image dimensions exceed limits ({}x{})", $width, $height); } if $dummy { vec![0] diff --git a/src/lib.rs b/src/lib.rs index 9760327..d83eca2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,7 @@ pub use decoders::cfa::CFA; #[doc(hidden)] pub use decoders::RawLoader; lazy_static! { - static ref LOADER: RawLoader = decoders::RawLoader::new(); + static ref LOADER: RawLoader = RawLoader::new(); } use std::path::Path;