Skip to content

Commit

Permalink
Fix invalid slice conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
l4l committed Mar 10, 2024
1 parent 71e3d19 commit 4c45b4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ impl Window {
// - it does not alias with original reference as it's been shadowed
// - len does not overflow as it reduced from the valid len
// - lifetimes are same
unsafe { std::mem::transmute::<&mut [u8], &mut [u32]>(a) }
unsafe {
&mut *std::ptr::slice_from_raw_parts_mut(a.as_mut_ptr().cast(), a.len() / 4)
}
}
let canvas = transmute_slice(canvas);
DrawTarget::from_backing(width, height, canvas)
Expand Down

0 comments on commit 4c45b4e

Please sign in to comment.