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;