Skip to content

Commit

Permalink
Go through as_mut_ptr instead of as_ptr to mutate
Browse files Browse the repository at this point in the history
Going through `as_ptr` does not give write provenance
since it creates an intermediary shared reference.
  • Loading branch information
Nilstrieb authored and kornelski committed Jun 18, 2022
1 parent 91ba4e6 commit 5b5c9ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/internal/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ unsafe fn from_items_to_struct<F, T>(from: &[F]) -> &[T] {
unsafe fn from_items_to_struct_mut<F, T>(from: &mut [F]) -> &mut [T] {
debug_assert_eq!(0, mem::size_of::<T>() % mem::size_of::<F>());
let len = from.len() / (mem::size_of::<T>() / mem::size_of::<F>());
slice::from_raw_parts_mut(from.as_ptr() as *mut T, len)
slice::from_raw_parts_mut(from.as_mut_ptr() as *mut T, len)
}

macro_rules! rgb_impl_from {
Expand Down

0 comments on commit 5b5c9ac

Please sign in to comment.