mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
fix(sort): explicitly clean up temp directory in TmpDirWrapper::Drop
The `TmpDirWrapper::Drop` only cleared handler state without attempting to delete the temporary directory. Cleanup relied entirely on the inner `TempDir::Drop`, which silently ignores errors via `let _ = remove_dir_all()`, potentially leaking `/tmp/uutils_sortXXXX` directories. Now `remove_tmp_dir` is called explicitly before `TempDir::Drop` runs, providing a safety net for cases where the silent cleanup would fail. Closes: #11728
This commit is contained in:
@@ -171,6 +171,15 @@ impl Drop for TmpDirWrapper {
|
||||
guard.lock = None;
|
||||
guard.path = None;
|
||||
}
|
||||
drop(guard);
|
||||
|
||||
// Explicitly attempt cleanup before TempDir's Drop runs silently.
|
||||
// TempDir::drop uses `let _ = remove_dir_all()` which silently
|
||||
// ignores errors, potentially leaking the directory.
|
||||
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
|
||||
if let Some(ref temp_dir) = self.temp_dir {
|
||||
let _ = remove_tmp_dir(temp_dir.path());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user