File tree 1 file changed +5
-2
lines changed
src/tools/miri/src/shims/unix
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 {
149
149
// to handle possible errors correctly.
150
150
let result = self . file . sync_all ( ) ;
151
151
// Now we actually close the file and return the result.
152
+ drop ( * self ) ;
152
153
interp_ok ( result)
153
154
} else {
154
155
// We drop the file, this closes it but ignores any errors
@@ -157,6 +158,7 @@ impl FileDescription for FileHandle {
157
158
// `/dev/urandom` which are read-only. Check
158
159
// https://github.com/rust-lang/miri/issues/999#issuecomment-568920439
159
160
// for a deeper discussion.
161
+ drop ( * self ) ;
160
162
interp_ok ( Ok ( ( ) ) )
161
163
}
162
164
}
@@ -1247,12 +1249,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1247
1249
return this. set_last_error_and_return_i32 ( LibcError ( "EBADF" ) ) ;
1248
1250
}
1249
1251
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 {
1251
1253
return this. set_last_error_and_return_i32 ( LibcError ( "EBADF" ) ) ;
1252
1254
} ;
1253
- if let Some ( entry) = open_dir. entry {
1255
+ if let Some ( entry) = open_dir. entry . take ( ) {
1254
1256
this. deallocate_ptr ( entry, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
1255
1257
}
1258
+ // We drop the `open_dir`, which will close the host dir handle.
1256
1259
drop ( open_dir) ;
1257
1260
1258
1261
interp_ok ( Scalar :: from_i32 ( 0 ) )
You can’t perform that action at this time.
0 commit comments