Skip to content

Commit c2901a9

Browse files
committed
use is_null_ptr instead of to_bits_or_ptr
1 parent b94890e commit c2901a9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/shims/foreign_items.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,11 @@ 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()?.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),
640+
let dtor = match this.read_scalar(args[1])?.not_undef()?;
641+
let dtor = if dtor.is_null_ptr() {
642+
Some(this.memory().get_fn(dtor_ptr)?.as_instance()?)
643+
} else {
644+
None
646645
};
647646

648647
// Figure out how large a pthread TLS key actually is.

0 commit comments

Comments
 (0)