Skip to content

Commit 980f3c3

Browse files
committed
fix UAF in doctest
1 parent b9e0607 commit 980f3c3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,8 @@ impl<R, W> VolatilePtr<'_, [u8], Access<R, W>> {
899899
/// use volatile::VolatilePtr;
900900
/// use core::ptr::NonNull;
901901
///
902-
/// let mut buf = unsafe { VolatilePtr::new_read_write(NonNull::from(vec![0; 10].as_mut_slice())) };
902+
/// let mut vec = vec![0; 10];
903+
/// let mut buf = unsafe { VolatilePtr::new_read_write(NonNull::from(vec.as_mut_slice())) };
903904
/// buf.fill(1);
904905
/// assert_eq!(unsafe { buf.as_ptr().as_mut() }, &mut vec![1; 10]);
905906
/// ```

0 commit comments

Comments
 (0)