Skip to content

Commit e24a6bf

Browse files
committed
FIX: Close dir handle when the last strong reference becomes dropped
1 parent 42b4b95 commit e24a6bf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/list.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ impl Iterator for DirIter {
177177

178178
impl Drop for DirIter {
179179
fn drop(&mut self) {
180-
unsafe {
181-
libc::closedir(*self.dir);
180+
if Arc::strong_count(self) == 1 {
181+
unsafe {
182+
libc::closedir(*self.dir);
183+
}
182184
}
183185
}
184186
}

0 commit comments

Comments
 (0)