From 496a2f31cff7c7f93ad883f6f211ccf4123e9556 Mon Sep 17 00:00:00 2001 From: Andrew Champion Date: Sat, 2 Mar 2019 12:29:11 -0500 Subject: [PATCH] Convert panic to error for writing wrong size strip --- src/encoder/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index f66ef71..a1da74e 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -474,7 +474,11 @@ impl<'a, W: Write + Seek, T: ColorType> ImageEncoder<'a, W, T> { { // TODO: Compression let samples = self.next_strip_sample_count(); - assert_eq!(value.len() as u64, samples); + if value.len() as u64 != samples { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidData, + "Slice is wrong size for strip").into()); + } let offset = self.encoder.write_data(value)?; self.strip_offsets.push(offset as u32);