Skip to content

Commit

Permalink
miri: fix memory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed May 3, 2024
1 parent b6d8dee commit 48e952a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,14 @@ impl<'a> ArchiveHeaderIterator<'a> {

/// Parse the memory at the given block as [`PosixHeader`].
fn block_as_header(&self, block_index: usize) -> &'a PosixHeader {
let hdr_ptr = &self.archive_data[block_index * BLOCKSIZE];
unsafe { (hdr_ptr as *const u8).cast::<PosixHeader>().as_ref() }.unwrap()
unsafe {
self.archive_data
.as_ptr()
.add(block_index * BLOCKSIZE)
.cast::<PosixHeader>()
.as_ref()
.unwrap()
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ SOFTWARE.
//! ```rust
//! use tar_no_std::TarArchiveRef;
//!
//! // log: not mandatory
//! std::env::set_var("RUST_LOG", "trace");
//! env_logger::init();
//!
//! // also works in no_std environment (except the println!, of course)
//! let archive = include_bytes!("../tests/gnu_tar_default.tar");
//! let archive = TarArchiveRef::new(archive).unwrap();
Expand Down

0 comments on commit 48e952a

Please sign in to comment.