Skip to content

Commit

Permalink
Remove potential panic in split_init
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Oct 16, 2024
1 parent 8adb366 commit 1ecf03f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pub(super) unsafe fn split_init(
buf: &mut [MaybeUninit<u8>],
init: usize,
) -> (&mut [u8], &mut [MaybeUninit<u8>]) {
let (init, uninit) = buf.split_at_mut(init);
debug_assert!(buf.len() <= init);
let (init, uninit) = buf.split_at_mut_unchecked(init);
let init = slice::from_raw_parts_mut(init.as_mut_ptr().cast::<u8>(), init.len());
(init, uninit)
}

0 comments on commit 1ecf03f

Please sign in to comment.