@@ -71,13 +71,13 @@ impl<'tcx> UnixEnvVars<'tcx> {
7171 self . environ . ptr ( )
7272 }
7373
74- /// Implementation detail for [`InterpCx::get_var `]. This basically does `getenv`, complete
74+ /// Implementation detail for [`InterpCx::get_env_var `]. This basically does `getenv`, complete
7575 /// with the reads of the environment, but returns an [`OsString`] instead of a pointer.
7676 pub ( crate ) fn get < ' mir > (
7777 & self ,
7878 ecx : & InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ,
7979 name : & OsStr ,
80- ) -> InterpResult < ' tcx , Option < OsString > > {
80+ ) -> InterpResult < ' tcx , Option < Pointer < Option < Provenance > > > > {
8181 // We don't care about the value as we have the `map` to keep track of everything,
8282 // but we do want to do this read so it shows up as a data race.
8383 let _vars_ptr = ecx. read_pointer ( & self . environ ) ?;
@@ -89,7 +89,7 @@ impl<'tcx> UnixEnvVars<'tcx> {
8989 Size :: from_bytes ( u64:: try_from ( name. len ( ) ) . unwrap ( ) . checked_add ( 1 ) . unwrap ( ) ) ,
9090 ecx,
9191 ) ?;
92- ecx . read_os_str_from_c_str ( var_ptr ) . map ( |s| Some ( s . to_owned ( ) ) )
92+ Ok ( Some ( var_ptr ) )
9393 }
9494}
9595
@@ -137,19 +137,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
137137 let name_ptr = this. read_pointer ( name_op) ?;
138138 let name = this. read_os_str_from_c_str ( name_ptr) ?;
139139
140- // We don't care about the value as we have the `map` to keep track of everything,
141- // but we do want to do this read so it shows up as a data race.
142- let _vars_ptr = this. read_pointer ( & this. machine . env_vars . unix ( ) . environ ) ?;
143- Ok ( match this. machine . env_vars . unix ( ) . map . get ( name) {
144- Some ( var_ptr) => {
145- // The offset is used to strip the "{name}=" part of the string.
146- var_ptr. offset (
147- Size :: from_bytes ( u64:: try_from ( name. len ( ) ) . unwrap ( ) . checked_add ( 1 ) . unwrap ( ) ) ,
148- this,
149- ) ?
150- }
151- None => Pointer :: null ( ) ,
152- } )
140+ let var_ptr = this. machine . env_vars . unix ( ) . get ( this, name) ?;
141+ Ok ( var_ptr. unwrap_or_else ( Pointer :: null) )
153142 }
154143
155144 fn setenv (
0 commit comments