Skip to content

Commit cac5c92

Browse files
Berrysoftsunfishcode
authored andcommitted
Fix port_getn calling. (#1215)
* Fix `port_getn` calling. * Return immediately if the vector's capacity is 0.
1 parent 0c2061c commit cac5c92

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/backend/libc/event/syscalls.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,15 @@ pub(crate) fn port_getn(
314314
events: &mut Vec<Event>,
315315
mut nget: u32,
316316
) -> io::Result<()> {
317+
if events.capacity() == 0 {
318+
return Ok(());
319+
}
317320
let timeout = timeout.map_or(null_mut(), as_mut_ptr);
318321
unsafe {
319322
ret(c::port_getn(
320323
borrowed_fd(port),
321324
events.as_mut_ptr().cast(),
322-
events.len().try_into().unwrap(),
325+
events.capacity().try_into().unwrap(),
323326
&mut nget,
324327
timeout,
325328
))?;

0 commit comments

Comments
 (0)