@@ -50,7 +50,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
5050                . memory 
5151                . allocate ( Size :: from_bytes ( size) ,  align,  kind. into ( ) ) ; 
5252            if  zero_init { 
53-                 // We just allocated this, the access cannot fail  
53+                 // We just allocated this, the access is definitely in-bounds.  
5454                this. memory 
5555                    . get_mut ( ptr. alloc_id ) 
5656                    . unwrap ( ) 
@@ -227,7 +227,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
227227                    Align :: from_bytes ( align) . unwrap ( ) , 
228228                    MiriMemoryKind :: Rust . into ( ) , 
229229                ) ; 
230-                 // We just allocated this, the access cannot fail  
230+                 // We just allocated this, the access is definitely in-bounds.  
231231                this. memory 
232232                    . get_mut ( ptr. alloc_id ) 
233233                    . unwrap ( ) 
@@ -643,7 +643,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
643643
644644            // Hook pthread calls that go to the thread-local storage memory subsystem. 
645645            "pthread_key_create"  => { 
646-                 let  key_ptr  = this. read_scalar ( args[ 0 ] ) ? . not_undef ( ) ?; 
646+                 let  key_place  = this. deref_operand ( args[ 0 ] ) ?; 
647647
648648                // Extract the function type out of the signature (that seems easier than constructing it ourselves). 
649649                let  dtor = match  this. test_null ( this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?) ? { 
@@ -668,16 +668,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
668668                    throw_unsup ! ( OutOfTls ) ; 
669669                } 
670670
671-                 let  key_ptr = this
672-                     . memory 
673-                     . check_ptr_access ( key_ptr,  key_layout. size ,  key_layout. align . abi ) ?
674-                     . expect ( "cannot be a ZST" ) ; 
675-                 this. memory . get_mut ( key_ptr. alloc_id ) ?. write_scalar ( 
676-                     tcx, 
677-                     key_ptr, 
678-                     Scalar :: from_uint ( key,  key_layout. size ) . into ( ) , 
679-                     key_layout. size , 
680-                 ) ?; 
671+                 this. write_scalar ( Scalar :: from_uint ( key,  key_layout. size ) ,  key_place. into ( ) ) ?; 
681672
682673                // Return success (`0`). 
683674                this. write_null ( dest) ?; 
@@ -856,6 +847,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
856847                let  system_info_ptr = this
857848                    . check_mplace_access ( system_info,  None ) ?
858849                    . expect ( "cannot be a ZST" ) ; 
850+                 // We rely on `deref_operand` doing bounds checks for us. 
859851                // Initialize with `0`. 
860852                this. memory 
861853                    . get_mut ( system_info_ptr. alloc_id ) ?
@@ -992,6 +984,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
992984    fn  set_last_error ( & mut  self ,  scalar :  Scalar < Tag > )  -> InterpResult < ' tcx >  { 
993985        let  this = self . eval_context_mut ( ) ; 
994986        let  errno_ptr = this. machine . last_error . unwrap ( ) ; 
987+         // We allocated this during machine initialziation so the bounds are fine. 
995988        this. memory . get_mut ( errno_ptr. alloc_id ) ?. write_scalar ( 
996989            & * this. tcx , 
997990            errno_ptr, 
0 commit comments