From b91f6a602fb52efeee06e8fa503bc9f161d226fa Mon Sep 17 00:00:00 2001 From: Michael Leonhard Date: Wed, 23 Mar 2022 16:43:51 -0700 Subject: [PATCH] Remove single use of `unsafe`. --- src/gzip.rs | 2 +- src/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gzip.rs b/src/gzip.rs index 2799275..8bc3a39 100644 --- a/src/gzip.rs +++ b/src/gzip.rs @@ -442,7 +442,7 @@ where let mut cbuf = [0; 1]; reader.read_exact(&mut cbuf)?; if cbuf[0] == 0 { - return Ok(unsafe { CString::from_vec_unchecked(buf) }); + return Ok(CString::new(buf).unwrap()); } buf.push(cbuf[0]); } diff --git a/src/lib.rs b/src/lib.rs index 2e0cc31..4b8a3ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ //! A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP). +#![forbid(unsafe_code)] #![warn(missing_docs)] pub use finish::Finish;