Skip to content

Commit 1c757c7

Browse files
committed
Fix a race in the test_unistd::test_fchown test
The test was assuming that once dropped, a temporary file's file descriptor would be invalid. But it might not be, because another file might be opened with the same file descriptor. Instead, use an obviously invalid file descriptor.
1 parent a848ab5 commit 1c757c7

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

test/test_unistd.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::ffi::CString;
1919
use std::fs::DirBuilder;
2020
use std::fs::{self, File};
2121
use std::io::Write;
22-
use std::mem;
2322
use std::os::unix::prelude::*;
2423
#[cfg(not(target_os = "redox"))]
2524
use std::path::Path;
@@ -466,9 +465,7 @@ fn test_fchown() {
466465
fchown(fd, uid, gid).unwrap();
467466
fchown(fd, uid, None).unwrap();
468467
fchown(fd, None, gid).unwrap();
469-
470-
mem::drop(path);
471-
fchown(fd, uid, gid).unwrap_err();
468+
fchown(999999999, uid, gid).unwrap_err();
472469
}
473470

474471
#[test]

0 commit comments

Comments
 (0)