Skip to content

Commit 9f630af

Browse files
committed
fix aliasing issue in unix sleep function
1 parent ed96321 commit 9f630af

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/sys/unix/thread.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ impl Thread {
178178
tv_nsec: nsecs,
179179
};
180180
secs -= ts.tv_sec as u64;
181-
if libc::nanosleep(&ts, &mut ts) == -1 {
181+
let ts_ptr = &mut ts as *mut _;
182+
if libc::nanosleep(ts_ptr, ts_ptr) == -1 {
182183
assert_eq!(os::errno(), libc::EINTR);
183184
secs += ts.tv_sec as u64;
184185
nsecs = ts.tv_nsec;

0 commit comments

Comments
 (0)