From bc0d673af06e52be16ef8b5fa6c1d15217f40013 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 15 Nov 2021 11:41:40 -0500 Subject: [PATCH] Fix a hard error in clippy --- src/deflate/deflater.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/deflate/deflater.rs b/src/deflate/deflater.rs index ce502cb1..45db30f5 100644 --- a/src/deflate/deflater.rs +++ b/src/deflate/deflater.rs @@ -5,17 +5,7 @@ use libdeflater::{CompressionError, CompressionLvl, Compressor}; pub fn deflate(data: &[u8], max_size: &AtomicMin) -> PngResult> { let mut compressor = Compressor::new(CompressionLvl::best()); let capacity = max_size.get().unwrap_or(data.len() / 2); - let mut dest = Vec::with_capacity(capacity); - unsafe { - // This is ok because the Vec contains Copy-able data (u8) - // and because libdeflater wrapper doesn't try to read - // the bytes from the target. - // - // That said, it should be able to accept MaybeUninit instead, - // so I raised an upstream issue that should make this safer: - // https://github.com/adamkewley/libdeflater/issues/1 - dest.set_len(capacity); - } + let mut dest = vec![0; capacity]; let len = compressor .zlib_compress(data, &mut dest) .map_err(|err| match err {