From 86edc72c7efb3efbf43e3704ad56717a02253925 Mon Sep 17 00:00:00 2001 From: Noa <33094578+coolreader18@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:02:01 -0500 Subject: [PATCH] Fix miri UB --- vm/src/pyobjectrc.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vm/src/pyobjectrc.rs b/vm/src/pyobjectrc.rs index 02999e510..cfff137c4 100644 --- a/vm/src/pyobjectrc.rs +++ b/vm/src/pyobjectrc.rs @@ -57,11 +57,11 @@ type OnceBox = once_cell::unsync::OnceCell>; struct Erased; struct PyObjVTable { - drop_dealloc: unsafe fn(&mut PyObject), + drop_dealloc: unsafe fn(*mut PyObject), debug: unsafe fn(&PyObject, &mut fmt::Formatter) -> fmt::Result, } -unsafe fn drop_dealloc_obj(x: &mut PyObject) { - Box::from_raw(x as *mut PyObject as *mut PyInner); +unsafe fn drop_dealloc_obj(x: *mut PyObject) { + Box::from_raw(x as *mut PyInner); } unsafe fn debug_obj(x: &PyObject, f: &mut fmt::Formatter) -> fmt::Result { let x = &*(x as *const PyObject as *const PyInner); @@ -683,7 +683,7 @@ impl PyObjectRef { } let drop_dealloc = self.0.vtable.drop_dealloc; - unsafe { drop_dealloc(self.ptr.as_mut()) } + unsafe { drop_dealloc(self.ptr.as_ptr()) } } }