File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ impl FileDescription for FileHandle {
149149 // to handle possible errors correctly.
150150 let result = self . file . sync_all ( ) ;
151151 // Now we actually close the file and return the result.
152+ drop ( * self ) ;
152153 interp_ok ( result)
153154 } else {
154155 // We drop the file, this closes it but ignores any errors
@@ -157,6 +158,7 @@ impl FileDescription for FileHandle {
157158 // `/dev/urandom` which are read-only. Check
158159 // https://github.com/rust-lang/miri/issues/999#issuecomment-568920439
159160 // for a deeper discussion.
161+ drop ( * self ) ;
160162 interp_ok ( Ok ( ( ) ) )
161163 }
162164 }
@@ -1247,12 +1249,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
12471249 return this. set_last_error_and_return_i32 ( LibcError ( "EBADF" ) ) ;
12481250 }
12491251
1250- let Some ( open_dir) = this. machine . dirs . streams . remove ( & dirp) else {
1252+ let Some ( mut open_dir) = this. machine . dirs . streams . remove ( & dirp) else {
12511253 return this. set_last_error_and_return_i32 ( LibcError ( "EBADF" ) ) ;
12521254 } ;
1253- if let Some ( entry) = open_dir. entry {
1255+ if let Some ( entry) = open_dir. entry . take ( ) {
12541256 this. deallocate_ptr ( entry, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
12551257 }
1258+ // We drop the `open_dir`, which will close the host dir handle.
12561259 drop ( open_dir) ;
12571260
12581261 interp_ok ( Scalar :: from_i32 ( 0 ) )
You can’t perform that action at this time.
0 commit comments