From 980f3c3e001e096b735c50704791c0b2df73c04d Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sun, 3 Jul 2022 20:32:59 +0200 Subject: [PATCH] fix UAF in doctest --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4234d49..35153ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -899,7 +899,8 @@ impl VolatilePtr<'_, [u8], Access> { /// use volatile::VolatilePtr; /// use core::ptr::NonNull; /// - /// let mut buf = unsafe { VolatilePtr::new_read_write(NonNull::from(vec![0; 10].as_mut_slice())) }; + /// let mut vec = vec![0; 10]; + /// let mut buf = unsafe { VolatilePtr::new_read_write(NonNull::from(vec.as_mut_slice())) }; /// buf.fill(1); /// assert_eq!(unsafe { buf.as_ptr().as_mut() }, &mut vec![1; 10]); /// ```