Skip to content

Commit

Permalink
fix: Add changes needed in commit of mode validation to submodule (hu…
Browse files Browse the repository at this point in the history
…man error)
  • Loading branch information
jhg committed Apr 27, 2024
1 parent dd37995 commit db51a3a
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,7 @@ use error::PointerError;
#[cfg(all(feature = "std", feature = "lender"))]
mod lender;

#[inline]
fn validate_pointer_is_not_null<T>(pointer: *const T) -> Result<(), PointerError> {
if pointer.is_null() {
log::error!("Using a NULL pointer as an opaque pointer to Rust's data");
return Err(PointerError::Null);
}
return Ok(());
}

#[inline]
fn validate_pointer<T>(pointer: *const T) -> Result<(), PointerError> {
validate_pointer_is_not_null(pointer)?;
#[cfg(all(feature = "std", feature = "lender"))]
if !lender::is_lent(pointer) {
log::error!("Using an invalid pointer as an opaque pointer to Rust's data");
return Err(PointerError::Invalid);
}
return Ok(());
}
mod validation;

/// Get a heap-allocated raw pointer without ownership.
///
Expand Down

0 comments on commit db51a3a

Please sign in to comment.