@@ -119,22 +119,26 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
119
119
size_op : OpTy < ' tcx , Tag > ,
120
120
) -> InterpResult < ' tcx , Scalar < Tag > > {
121
121
let this = self . eval_context_mut ( ) ;
122
- let tcx = & { this. tcx . tcx } ;
123
122
124
- let buf = this. force_ptr ( this. read_scalar ( buf_op) ?. not_undef ( ) ?) ?;
125
- let size = this. read_scalar ( size_op) ?. to_usize ( & * this. tcx ) ?;
126
- // If we cannot get the current directory, we return null
127
- if let Ok ( cwd) = env:: current_dir ( ) {
128
- // It is not clear what happens with non-utf8 paths here
129
- let mut bytes = cwd. display ( ) . to_string ( ) . into_bytes ( ) ;
130
- // If the buffer is smaller than the path, we return null
131
- if bytes. len ( ) as u64 <= size {
132
- // We need `size` bytes exactly
133
- bytes. resize ( size as usize , 0 ) ;
134
- this. memory_mut ( ) . get_mut ( buf. alloc_id ) ?. write_bytes ( tcx, buf, & bytes) ?;
135
- return Ok ( Scalar :: Ptr ( buf) )
123
+ if this. machine . communicate {
124
+ let tcx = & { this. tcx . tcx } ;
125
+
126
+ let buf = this. force_ptr ( this. read_scalar ( buf_op) ?. not_undef ( ) ?) ?;
127
+ let size = this. read_scalar ( size_op) ?. to_usize ( & * this. tcx ) ?;
128
+ // If we cannot get the current directory, we return null
129
+ if let Ok ( cwd) = env:: current_dir ( ) {
130
+ // It is not clear what happens with non-utf8 paths here
131
+ let mut bytes = cwd. display ( ) . to_string ( ) . into_bytes ( ) ;
132
+ // If the buffer is smaller than the path, we return null
133
+ if bytes. len ( ) as u64 <= size {
134
+ // We need `size` bytes exactly
135
+ bytes. resize ( size as usize , 0 ) ;
136
+ this. memory_mut ( ) . get_mut ( buf. alloc_id ) ?. write_bytes ( tcx, buf, & bytes) ?;
137
+ return Ok ( Scalar :: Ptr ( buf) )
138
+ }
136
139
}
140
+ return Ok ( Scalar :: ptr_null ( & * this. tcx ) ) ;
137
141
}
138
- Ok ( Scalar :: ptr_null ( & * this . tcx ) )
142
+ throw_unsup_format ! ( "Function not available when isolation is enabled" )
139
143
}
140
144
}
0 commit comments