@@ -69,7 +69,7 @@ impl<'tcx> EnvVars<'tcx> {
6969 }
7070 // Deallocate environ var list.
7171 let environ = ecx. machine . env_vars . environ . unwrap ( ) ;
72- let old_vars_ptr = ecx. read_scalar ( environ. into ( ) ) ?. not_undef ( ) ?;
72+ let old_vars_ptr = ecx. read_scalar ( environ. into ( ) ) ?. check_init ( ) ?;
7373 ecx. memory . deallocate ( ecx. force_ptr ( old_vars_ptr) ?, None , MiriMemoryKind :: Env . into ( ) ) ?;
7474 Ok ( ( ) )
7575 }
@@ -104,7 +104,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
104104 let target_os = & this. tcx . sess . target . target . target_os ;
105105 assert ! ( target_os == "linux" || target_os == "macos" , "`getenv` is only available for the UNIX target family" ) ;
106106
107- let name_ptr = this. read_scalar ( name_op) ?. not_undef ( ) ?;
107+ let name_ptr = this. read_scalar ( name_op) ?. check_init ( ) ?;
108108 let name = this. read_os_str_from_c_str ( name_ptr) ?;
109109 Ok ( match this. machine . env_vars . map . get ( name) {
110110 Some ( var_ptr) => {
@@ -125,7 +125,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
125125 let this = self . eval_context_mut ( ) ;
126126 this. assert_target_os ( "windows" , "GetEnvironmentVariableW" ) ;
127127
128- let name_ptr = this. read_scalar ( name_op) ?. not_undef ( ) ?;
128+ let name_ptr = this. read_scalar ( name_op) ?. check_init ( ) ?;
129129 let name = this. read_os_str_from_wide_str ( name_ptr) ?;
130130 Ok ( match this. machine . env_vars . map . get ( & name) {
131131 Some ( var_ptr) => {
@@ -135,7 +135,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
135135 let var_ptr = Scalar :: from ( var_ptr. offset ( Size :: from_bytes ( name_offset_bytes) , this) ?) ;
136136 let var = this. read_os_str_from_wide_str ( var_ptr) ?;
137137
138- let buf_ptr = this. read_scalar ( buf_op) ?. not_undef ( ) ?;
138+ let buf_ptr = this. read_scalar ( buf_op) ?. check_init ( ) ?;
139139 // `buf_size` represents the size in characters.
140140 let buf_size = u64:: from ( this. read_scalar ( size_op) ?. to_u32 ( ) ?) ;
141141 windows_check_buffer_size ( this. write_os_str_to_wide_str ( & var, buf_ptr, buf_size) ?)
@@ -153,7 +153,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
153153 let this = self . eval_context_mut ( ) ;
154154 this. assert_target_os ( "windows" , "GetEnvironmentStringsW" ) ;
155155
156- // Info on layout of environment blocks in Windows:
156+ // Info on layout of environment blocks in Windows:
157157 // https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables
158158 let mut env_vars = std:: ffi:: OsString :: new ( ) ;
159159 for & item in this. machine . env_vars . map . values ( ) {
@@ -173,7 +173,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
173173 let this = self . eval_context_mut ( ) ;
174174 this. assert_target_os ( "windows" , "FreeEnvironmentStringsW" ) ;
175175
176- let env_block_ptr = this. read_scalar ( env_block_op) ?. not_undef ( ) ?;
176+ let env_block_ptr = this. read_scalar ( env_block_op) ?. check_init ( ) ?;
177177 let result = this. memory . deallocate ( this. force_ptr ( env_block_ptr) ?, None , MiriMemoryKind :: Env . into ( ) ) ;
178178 // If the function succeeds, the return value is nonzero.
179179 Ok ( result. is_ok ( ) as i32 )
@@ -188,8 +188,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
188188 let target_os = & this. tcx . sess . target . target . target_os ;
189189 assert ! ( target_os == "linux" || target_os == "macos" , "`setenv` is only available for the UNIX target family" ) ;
190190
191- let name_ptr = this. read_scalar ( name_op) ?. not_undef ( ) ?;
192- let value_ptr = this. read_scalar ( value_op) ?. not_undef ( ) ?;
191+ let name_ptr = this. read_scalar ( name_op) ?. check_init ( ) ?;
192+ let value_ptr = this. read_scalar ( value_op) ?. check_init ( ) ?;
193193
194194 let mut new = None ;
195195 if !this. is_null ( name_ptr) ? {
@@ -224,14 +224,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
224224 let mut this = self . eval_context_mut ( ) ;
225225 this. assert_target_os ( "windows" , "SetEnvironmentVariableW" ) ;
226226
227- let name_ptr = this. read_scalar ( name_op) ?. not_undef ( ) ?;
228- let value_ptr = this. read_scalar ( value_op) ?. not_undef ( ) ?;
227+ let name_ptr = this. read_scalar ( name_op) ?. check_init ( ) ?;
228+ let value_ptr = this. read_scalar ( value_op) ?. check_init ( ) ?;
229229
230230 if this. is_null ( name_ptr) ? {
231231 // ERROR CODE is not clearly explained in docs.. For now, throw UB instead.
232232 throw_ub_format ! ( "pointer to environment variable name is NULL" ) ;
233233 }
234-
234+
235235 let name = this. read_os_str_from_wide_str ( name_ptr) ?;
236236 if name. is_empty ( ) {
237237 throw_unsup_format ! ( "environment variable name is an empty string" ) ;
@@ -261,7 +261,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
261261 let target_os = & this. tcx . sess . target . target . target_os ;
262262 assert ! ( target_os == "linux" || target_os == "macos" , "`unsetenv` is only available for the UNIX target family" ) ;
263263
264- let name_ptr = this. read_scalar ( name_op) ?. not_undef ( ) ?;
264+ let name_ptr = this. read_scalar ( name_op) ?. check_init ( ) ?;
265265 let mut success = None ;
266266 if !this. is_null ( name_ptr) ? {
267267 let name = this. read_os_str_from_c_str ( name_ptr) ?. to_owned ( ) ;
@@ -295,7 +295,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
295295
296296 this. check_no_isolation ( "getcwd" ) ?;
297297
298- let buf = this. read_scalar ( buf_op) ?. not_undef ( ) ?;
298+ let buf = this. read_scalar ( buf_op) ?. check_init ( ) ?;
299299 let size = this. read_scalar ( size_op) ?. to_machine_usize ( & * this. tcx ) ?;
300300 // If we cannot get the current directory, we return null
301301 match env:: current_dir ( ) {
@@ -323,7 +323,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
323323 this. check_no_isolation ( "GetCurrentDirectoryW" ) ?;
324324
325325 let size = u64:: from ( this. read_scalar ( size_op) ?. to_u32 ( ) ?) ;
326- let buf = this. read_scalar ( buf_op) ?. not_undef ( ) ?;
326+ let buf = this. read_scalar ( buf_op) ?. check_init ( ) ?;
327327
328328 // If we cannot get the current directory, we return 0
329329 match env:: current_dir ( ) {
@@ -341,7 +341,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
341341
342342 this. check_no_isolation ( "chdir" ) ?;
343343
344- let path = this. read_path_from_c_str ( this. read_scalar ( path_op) ?. not_undef ( ) ?) ?;
344+ let path = this. read_path_from_c_str ( this. read_scalar ( path_op) ?. check_init ( ) ?) ?;
345345
346346 match env:: set_current_dir ( path) {
347347 Ok ( ( ) ) => Ok ( 0 ) ,
@@ -362,7 +362,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
362362
363363 this. check_no_isolation ( "SetCurrentDirectoryW" ) ?;
364364
365- let path = this. read_path_from_wide_str ( this. read_scalar ( path_op) ?. not_undef ( ) ?) ?;
365+ let path = this. read_path_from_wide_str ( this. read_scalar ( path_op) ?. check_init ( ) ?) ?;
366366
367367 match env:: set_current_dir ( path) {
368368 Ok ( ( ) ) => Ok ( 1 ) ,
@@ -379,7 +379,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
379379 let this = self . eval_context_mut ( ) ;
380380 // Deallocate the old environ list, if any.
381381 if let Some ( environ) = this. machine . env_vars . environ {
382- let old_vars_ptr = this. read_scalar ( environ. into ( ) ) ?. not_undef ( ) ?;
382+ let old_vars_ptr = this. read_scalar ( environ. into ( ) ) ?. check_init ( ) ?;
383383 this. memory . deallocate ( this. force_ptr ( old_vars_ptr) ?, None , MiriMemoryKind :: Env . into ( ) ) ?;
384384 } else {
385385 // No `environ` allocated yet, let's do that.
0 commit comments