Skip to content

Commit

Permalink
assert MsgHdr::with_control with empty buffer which causes error in m…
Browse files Browse the repository at this point in the history
…acOS
  • Loading branch information
youknowone committed Apr 22, 2024
1 parent 6923954 commit d4c8d9b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,11 @@ impl<'addr, 'bufs, 'control> MsgHdr<'addr, 'bufs, 'control> {
/// Corresponds to setting `msg_control` and `msg_controllen` on Unix and
/// `Control` on Windows.
pub fn with_control(mut self, buf: &'control [u8]) -> Self {
let ptr = buf.as_ptr() as *mut _;
sys::set_msghdr_control(&mut self.inner, ptr, buf.len());
debug_assert!(
!buf.is_empty(),
"Empty control buffer might be a programming error"
);
sys::set_msghdr_control(&mut self.inner, buf.as_ptr() as *mut _, buf.len());
self
}

Expand Down

0 comments on commit d4c8d9b

Please sign in to comment.