From 25519e5290b4e04ab7a6cb07bcda01a542a0b1f3 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Mon, 13 Jan 2020 08:04:48 +0000 Subject: [PATCH] Fix destructor in emcc.rs --- src/libpanic_unwind/emcc.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libpanic_unwind/emcc.rs b/src/libpanic_unwind/emcc.rs index 0f93140238b..9161d49959c 100644 --- a/src/libpanic_unwind/emcc.rs +++ b/src/libpanic_unwind/emcc.rs @@ -88,8 +88,12 @@ pub unsafe fn panic(data: Box) -> u32 { } extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> DestructorRet { unsafe { - ptr::drop_in_place(ptr as *mut Exception); - super::__rust_drop_panic(); + if let Some(b) = (ptr as *mut Exception).read().data { + drop(b); + super::__rust_drop_panic(); + } + #[cfg(any(target_arch = "arm", target_arch = "wasm32"))] + ptr } }