Skip to content

Commit

Permalink
Fix dangling pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
MikailBag committed Jul 26, 2020
1 parent ef6d358 commit 3ea3a53
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/poll.rs
Expand Up @@ -135,11 +135,7 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result<libc::c_int> {
///
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
pub fn ppoll(fds: &mut [PollFd], timeout: Option<TimeSpec>, sigmask: SigSet) -> Result<libc::c_int> {
let timeout = match timeout {
Some(t) => t.as_ref(),
None => core::ptr::null()
};

let timeout = timeout.as_ref().map_or(core::ptr::null(), |r| r.as_ref());
let res = unsafe {
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
fds.len() as libc::nfds_t,
Expand Down

0 comments on commit 3ea3a53

Please sign in to comment.