diff --git a/core/src/allocator/rust.rs b/core/src/allocator/rust.rs index 6eba6ed8..4ea28cc5 100644 --- a/core/src/allocator/rust.rs +++ b/core/src/allocator/rust.rs @@ -116,10 +116,12 @@ mod test { struct TestAllocator; unsafe impl Allocator for TestAllocator { - unsafe fn alloc(&mut self, size: usize) -> crate::allocator::RawMemPtr { - let res = RustAllocator.alloc(size); - ALLOC_SIZE.fetch_add(RustAllocator::usable_size(res), Ordering::AcqRel); - res + fn alloc(&mut self, size: usize) -> crate::allocator::RawMemPtr { + unsafe { + let res = RustAllocator.alloc(size); + ALLOC_SIZE.fetch_add(RustAllocator::usable_size(res), Ordering::AcqRel); + res + } } unsafe fn dealloc(&mut self, ptr: crate::allocator::RawMemPtr) { diff --git a/core/src/runtime/async.rs b/core/src/runtime/async.rs index 650dad92..7ddeb257 100644 --- a/core/src/runtime/async.rs +++ b/core/src/runtime/async.rs @@ -286,11 +286,12 @@ impl AsyncRuntime { lock.drop_pending(); loop { - match lock.runtime.execute_pending_job().map_err(|e| { + let pending = lock.runtime.execute_pending_job().map_err(|e| { let ptr = NonNull::new(e) .expect("executing pending job returned a null context on error"); AsyncJobException(unsafe { AsyncContext::from_raw(ptr, self.clone()) }) - }) { + }); + match pending { Err(e) => { // SAFETY: Runtime is already locked so creating a context is safe. let ctx = unsafe { Ctx::from_ptr(e.0 .0.ctx.as_ptr()) }; diff --git a/core/src/runtime/raw.rs b/core/src/runtime/raw.rs index 22c7b1ad..daa45340 100644 --- a/core/src/runtime/raw.rs +++ b/core/src/runtime/raw.rs @@ -232,10 +232,11 @@ impl RawRuntime { _rt: *mut qjs::JSRuntime, opaque: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let should_interrupt = match panic::catch_unwind(move || { + let catch_unwind = panic::catch_unwind(move || { let opaque = &mut *(opaque as *mut Opaque); opaque.interrupt_handler.as_mut().expect("handler is set")() - }) { + }); + let should_interrupt = match catch_unwind { Ok(should_interrupt) => should_interrupt, Err(panic) => { let opaque = &mut *(opaque as *mut Opaque);