diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 108af1c08..f2d8674c0 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -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 } } };