@@ -50,8 +50,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
50
50
) -> InterpResult < ' tcx > {
51
51
let this = self . eval_context_mut ( ) ;
52
52
if !ptr. is_null_ptr ( this) {
53
+ let ptr = this. force_ptr ( ptr) ?;
53
54
this. memory_mut ( ) . deallocate (
54
- ptr. to_ptr ( ) ? ,
55
+ ptr,
55
56
None ,
56
57
MiriMemoryKind :: C . into ( ) ,
57
58
) ?;
@@ -78,7 +79,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
78
79
Ok ( Scalar :: Ptr ( new_ptr) )
79
80
}
80
81
} else {
81
- let old_ptr = old_ptr . to_ptr ( ) ?;
82
+ let old_ptr = this . force_ptr ( old_ptr ) ?;
82
83
let memory = this. memory_mut ( ) ;
83
84
let old_size = Size :: from_bytes ( memory. get ( old_ptr. alloc_id ) ?. bytes . len ( ) as u64 ) ;
84
85
if new_size == 0 {
@@ -234,7 +235,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
234
235
this. write_scalar ( Scalar :: Ptr ( ptr) , dest) ?;
235
236
}
236
237
"__rust_dealloc" => {
237
- let ptr = this. read_scalar ( args[ 0 ] ) ?. to_ptr ( ) ?;
238
+ let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
238
239
let old_size = this. read_scalar ( args[ 1 ] ) ?. to_usize ( this) ?;
239
240
let align = this. read_scalar ( args[ 2 ] ) ?. to_usize ( this) ?;
240
241
if old_size == 0 {
@@ -243,6 +244,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
243
244
if !align. is_power_of_two ( ) {
244
245
return err ! ( HeapAllocNonPowerOfTwoAlignment ( align) ) ;
245
246
}
247
+ let ptr = this. force_ptr ( ptr) ?;
246
248
this. memory_mut ( ) . deallocate (
247
249
ptr,
248
250
Some ( ( Size :: from_bytes ( old_size) , Align :: from_bytes ( align) . unwrap ( ) ) ) ,
0 commit comments