From 86a72ea127bd962de9daabe838aafa4a92d7368f Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 7 Oct 2022 03:50:33 +0100 Subject: [PATCH] Avoid printing output bytes on decompress error Instead, print the number of bytes decompressed so far Fixes #452 --- src/deflate/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/deflate/mod.rs b/src/deflate/mod.rs index 9894a5b0..e1b4fdf9 100644 --- a/src/deflate/mod.rs +++ b/src/deflate/mod.rs @@ -27,8 +27,13 @@ pub mod cfzlib { /// Decompress a data stream using the DEFLATE algorithm pub fn inflate(data: &[u8]) -> PngResult> { - miniz_oxide::inflate::decompress_to_vec_zlib(data) - .map_err(|e| PngError::new(&format!("Error on decompress: {:?}", e))) + miniz_oxide::inflate::decompress_to_vec_zlib(data).map_err(|e| { + PngError::new(&format!( + "Error on decompress: {:?} (after {:?} decompressed bytes)", + e.status, + e.output.len() + )) + }) } /// Compress a data stream using the DEFLATE algorithm