diff --git a/src/context.rs b/src/context.rs index 29bc53b2c228b3aef074ec18ce663074e0527f32..3867f5ad715ba38171d237948d828a92639765ca 100644 --- a/src/context.rs +++ b/src/context.rs @@ -5,6 +5,8 @@ use std::ffi::CStr; use std::os::raw::c_void; use std::cell::UnsafeCell; use std::collections::HashMap; +use std::panic::UnwindSafe; +use std::panic::RefUnwindSafe; /// A special case for non-thread-aware functions. /// @@ -14,6 +16,9 @@ pub struct GlobalContext { _not_thread_safe: UnsafeCell<YouMustUseThreadContextToShareBetweenThreads>, } +impl UnwindSafe for GlobalContext {} +impl RefUnwindSafe for GlobalContext {} + #[doc(hidden)] pub trait Context { fn as_ptr(&self) -> ffi::Context; diff --git a/src/profile.rs b/src/profile.rs index ac14c4f54829725d6c19448a79987a7dec09f2f2..de29608e90418d7e6d79c0f21ea453739aa99218 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -530,3 +530,11 @@ fn bad_icc() { let err = Profile::new_icc(&[1, 2, 3]); assert!(err.is_err()); } + +#[test] +fn unwind_safety() { + let ref profile = Profile::new_xyz(); + std::panic::catch_unwind(|| { + profile.clone() + }).unwrap(); +}