@@ -318,8 +318,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
318
318
319
319
"dlsym" => {
320
320
let _handle = this. read_scalar ( args[ 0 ] ) ?;
321
- let symbol = this. read_scalar ( args[ 1 ] ) ?. to_ptr ( ) ?;
322
- let symbol_name = this. memory ( ) . get ( symbol . alloc_id ) ? . read_c_str ( tcx , symbol) ?;
321
+ let symbol = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
322
+ let symbol_name = this. memory ( ) . read_c_str ( symbol) ?;
323
323
let err = format ! ( "bad c unicode symbol: {:?}" , symbol_name) ;
324
324
let symbol_name = :: std:: str:: from_utf8 ( symbol_name) . unwrap_or ( & err) ;
325
325
if let Some ( dlsym) = Dlsym :: from_str ( symbol_name) ? {
@@ -433,8 +433,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
433
433
434
434
"getenv" => {
435
435
let result = {
436
- let name_ptr = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
437
- let name = this. memory ( ) . get ( name_ptr . alloc_id ) ? . read_c_str ( tcx , name_ptr) ?;
436
+ let name_ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
437
+ let name = this. memory ( ) . read_c_str ( name_ptr) ?;
438
438
match this. machine . env_vars . get ( name) {
439
439
Some ( & var) => Scalar :: Ptr ( var) ,
440
440
None => Scalar :: ptr_null ( & * this. tcx ) ,
@@ -448,12 +448,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
448
448
{
449
449
let name_ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
450
450
if !this. is_null ( name_ptr) ? {
451
- let name_ptr = name_ptr. to_ptr ( ) ?;
452
- let name = this
453
- . memory ( )
454
- . get ( name_ptr. alloc_id ) ?
455
- . read_c_str ( tcx, name_ptr) ?
456
- . to_owned ( ) ;
451
+ let name = this. memory ( ) . read_c_str ( name_ptr) ?. to_owned ( ) ;
457
452
if !name. is_empty ( ) && !name. contains ( & b'=' ) {
458
453
success = Some ( this. machine . env_vars . remove ( & name) ) ;
459
454
}
@@ -473,11 +468,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
473
468
let mut new = None ;
474
469
{
475
470
let name_ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
476
- let value_ptr = this. read_scalar ( args[ 1 ] ) ?. to_ptr ( ) ?;
477
- let value = this. memory ( ) . get ( value_ptr . alloc_id ) ? . read_c_str ( tcx , value_ptr) ?;
471
+ let value_ptr = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
472
+ let value = this. memory ( ) . read_c_str ( value_ptr) ?;
478
473
if !this. is_null ( name_ptr) ? {
479
- let name_ptr = name_ptr. to_ptr ( ) ?;
480
- let name = this. memory ( ) . get ( name_ptr. alloc_id ) ?. read_c_str ( tcx, name_ptr) ?;
474
+ let name = this. memory ( ) . read_c_str ( name_ptr) ?;
481
475
if !name. is_empty ( ) && !name. contains ( & b'=' ) {
482
476
new = Some ( ( name. to_owned ( ) , value. to_owned ( ) ) ) ;
483
477
}
@@ -552,8 +546,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
552
546
}
553
547
554
548
"strlen" => {
555
- let ptr = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
556
- let n = this. memory ( ) . get ( ptr . alloc_id ) ? . read_c_str ( tcx , ptr) ?. len ( ) ;
549
+ let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
550
+ let n = this. memory ( ) . read_c_str ( ptr) ?. len ( ) ;
557
551
this. write_scalar ( Scalar :: from_uint ( n as u64 , dest. layout . size ) , dest) ?;
558
552
}
559
553
0 commit comments