diff --git a/src/backend/libc/event/syscalls.rs b/src/backend/libc/event/syscalls.rs index 272226faf..def689ebd 100644 --- a/src/backend/libc/event/syscalls.rs +++ b/src/backend/libc/event/syscalls.rs @@ -314,12 +314,15 @@ pub(crate) fn port_getn( events: &mut Vec, mut nget: u32, ) -> io::Result<()> { + if events.capacity() == 0 { + return Ok(()); + } let timeout = timeout.map_or(null_mut(), as_mut_ptr); unsafe { ret(c::port_getn( borrowed_fd(port), events.as_mut_ptr().cast(), - events.len().try_into().unwrap(), + events.capacity().try_into().unwrap(), &mut nget, timeout, ))?;