From 5212242934fc86220a600c2ccfb9dc95d9968adb Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Wed, 30 Aug 2023 16:50:03 +0200 Subject: [PATCH] Improve shape check --- crates/items_2/src/eventfull.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/items_2/src/eventfull.rs b/crates/items_2/src/eventfull.rs index d2a6173..331ed1b 100644 --- a/crates/items_2/src/eventfull.rs +++ b/crates/items_2/src/eventfull.rs @@ -345,8 +345,12 @@ impl EventFull { // NOTE // We only know the number of pixels from the compressed blob but we can't // know the actual shape. - // Can only rely on user input. - Ok(Shape::Image(*a, *b)) + // Can only rely on user input and check that total number of pixels agree. + if *a * *b != n { + Err(DecompError::ShapeMakesNoSense) + } else { + Ok(Shape::Image(*a, *b)) + } } } Err(_) => Err(DecompError::ShapeMakesNoSense),