fix raw fd drop.

This commit is contained in:
fakeshadow 2021-10-14 08:27:30 +08:00
parent 3e578e839b
commit 9ffabe946f
1 changed files with 3 additions and 1 deletions

View File

@ -197,7 +197,9 @@ impl NamedFile {
// SAFETY: fd is borrowed and lives longer than the unsafe block.
unsafe {
let fs = std::fs::File::from_raw_fd(fd);
fs.metadata()?
let md = fs.metadata()?;
std::mem::forget(fs);
md
}
}
};