diff --git a/zeroize/src/lib.rs b/zeroize/src/lib.rs index e6664c1f..1166d83c 100644 --- a/zeroize/src/lib.rs +++ b/zeroize/src/lib.rs @@ -805,6 +805,10 @@ unsafe fn volatile_set(dst: *mut T, src: T, count: usize) { #[inline(always)] pub unsafe fn zeroize_flat_type(data: *mut T) { let size = mem::size_of::(); + // Safety: + // + // This is safe because `mem::size_of()` returns the exact size of the object in memory, and + // `data_ptr` points directly to the first byte of the data. volatile_set(data as *mut u8, 0, size); atomic_fence() }