From fc9e3923f653881d0fcb326fd04c76ab6f6768bf Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Sun, 2 Dec 2018 21:05:37 -0700 Subject: [PATCH] drop DIR pointers again --- src/header/dirent/mod.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/header/dirent/mod.rs b/src/header/dirent/mod.rs index 195dfe9c..8696b9ad 100644 --- a/src/header/dirent/mod.rs +++ b/src/header/dirent/mod.rs @@ -57,20 +57,12 @@ pub unsafe extern "C" fn opendir(path: *const c_char) -> *mut DIR { #[no_mangle] pub unsafe extern "C" fn closedir(dir: *mut DIR) -> c_int { + let mut dir = Box::from_raw(dir); - let ret = { - let mut dir = Box::from_raw(dir); + let ret = Sys::close(*dir.file); - let ret = Sys::close(*dir.file); - - // Reference files aren't closed when dropped - dir.file.reference = true; - - //TODO: find out why dropping dir can crash - mem::forget(dir); - - ret - }; + // Reference files aren't closed when dropped + dir.file.reference = true; ret } -- GitLab