Skip to content

Commit 3feb7b0

Browse files
committed
refactor: Add logs and handle poisoned RwLock error
1 parent d46ea57 commit 3feb7b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ lazy_static! {
4242
#[cfg(all(feature = "std", feature = "lender"))]
4343
#[inline]
4444
fn invalid_error_check<T>(pointer: *const T) -> Result<(), crate::error::PointerError> {
45-
if !LENT_POINTERS.read().unwrap().contains(&(pointer as usize)) {
45+
if let Ok(lent_pointers) = LENT_POINTERS.read() {
46+
if !lent_pointers.contains(&(pointer as usize)) {
47+
log::error!("Using an invalid pointer as an opaque pointer to Rust's data");
48+
return Err(crate::error::PointerError::Invalid);
49+
}
50+
} else {
51+
log::error!("RwLock poisoned, it is not possible to check pointers");
4652
return Err(crate::error::PointerError::Invalid);
4753
}
4854
return Ok(());

0 commit comments

Comments
 (0)