@@ -902,13 +902,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
902
902
// pub d_name: [c_char; 256],
903
903
// }
904
904
905
- let entry_ptr = this. force_ptr ( this. read_scalar ( entry_op) ?. not_undef ( ) ?) ?;
906
- let dirent64_layout = this. libc_ty_layout ( "dirent64" ) ?;
907
- let name_offset = dirent64_layout. details . fields . offset ( 4 ) ;
908
- let name_ptr = entry_ptr. offset ( name_offset, this) ?;
905
+ let entry_place = this. deref_operand ( entry_op) ?;
906
+ let name_place = this. mplace_field ( entry_place, 4 ) ?;
909
907
910
908
let file_name = dir_entry. file_name ( ) ;
911
- let name_fits = this. write_os_str_to_c_str ( & file_name, Scalar :: Ptr ( name_ptr ) , 256 ) ?;
909
+ let name_fits = this. write_os_str_to_c_str ( & file_name, name_place . ptr , name_place . layout . size . bytes ( ) ) ?;
912
910
if !name_fits {
913
911
throw_unsup_format ! ( "A directory entry had a name too large to fit in libc::dirent64" ) ;
914
912
}
@@ -988,13 +986,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
988
986
// pub d_name: [c_char; 1024],
989
987
// }
990
988
991
- let entry_ptr = this. force_ptr ( this. read_scalar ( entry_op) ?. not_undef ( ) ?) ?;
992
- let dirent_layout = this. libc_ty_layout ( "dirent" ) ?;
993
- let name_offset = dirent_layout. details . fields . offset ( 5 ) ;
994
- let name_ptr = entry_ptr. offset ( name_offset, this) ?;
989
+ let entry_place = this. deref_operand ( entry_op) ?;
990
+ let name_place = this. mplace_field ( entry_place, 5 ) ?;
995
991
996
992
let file_name = dir_entry. file_name ( ) ;
997
- let name_fits = this. write_os_str_to_c_str ( & file_name, Scalar :: Ptr ( name_ptr ) , 1024 ) ?;
993
+ let name_fits = this. write_os_str_to_c_str ( & file_name, name_place . ptr , name_place . layout . size . bytes ( ) ) ?;
998
994
if !name_fits {
999
995
throw_unsup_format ! ( "A directory entry had a name too large to fit in libc::dirent" ) ;
1000
996
}
0 commit comments