@@ -317,7 +317,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
317317 // vtable_ptr: *mut usize,
318318 // ) -> u32
319319 // We abort on panic, so not much is going on here, but we still have to call the closure.
320- let f = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
320+ let f = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
321321 let data = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
322322 let f_instance = this. memory ( ) . get_fn ( f) ?. as_instance ( ) ?;
323323 this. write_null ( dest) ?;
@@ -637,14 +637,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
637637 let key_ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
638638
639639 // Extract the function type out of the signature (that seems easier than constructing it ourselves).
640- let dtor = match this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ? {
641- Scalar :: Ptr ( dtor_ptr) => Some ( this. memory ( ) . get_fn ( dtor_ptr) ?. as_instance ( ) ?) ,
642- Scalar :: Raw { data : 0 , size } => {
643- // NULL pointer
644- assert_eq ! ( size as u64 , this. memory( ) . pointer_size( ) . bytes( ) ) ;
645- None
646- } ,
647- Scalar :: Raw { .. } => return err ! ( ReadBytesAsPointer ) ,
640+ let dtor = match this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?. to_bits_or_ptr ( this. memory ( ) . pointer_size ( ) , tcx) {
641+ Err ( dtor_ptr) =>
642+ Some ( this. memory ( ) . get_fn ( dtor_ptr. into ( ) ) ?. as_instance ( ) ?) ,
643+ Ok ( 0 ) => // NULL pointer
644+ None ,
645+ Ok ( _) => return err ! ( ReadBytesAsPointer ) ,
648646 } ;
649647
650648 // Figure out how large a pthread TLS key actually is.
0 commit comments