Skip to content

Commit

Permalink
mod data: Make safe (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen authored Jun 21, 2024
2 parents 4100ec4 + 483c89a commit 41b267d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/data.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![deny(unsafe_op_in_unsafe_fn)]

use crate::include::common::validate::validate_input;
use crate::include::dav1d::common::Rav1dDataProps;
use crate::include::dav1d::data::Rav1dData;
Expand Down Expand Up @@ -39,7 +41,8 @@ impl Rav1dData {
) -> Rav1dResult<Self> {
let free = validate_input!(free_callback.ok_or(EINVAL))?;
let free = Free { free, cookie };
let data = CBox::from_c(data, free);
// SAFETY: Preconditions delegate to `CBox::from_c`'s safety.
let data = unsafe { CBox::from_c(data, free) };
let data = CArc::wrap(data)?;
Ok(data.into())
}
Expand All @@ -55,7 +58,8 @@ impl Rav1dData {
) -> Rav1dResult {
let free = validate_input!(free_callback.ok_or(EINVAL))?;
let free = Free { free, cookie };
let user_data = CBox::from_c(user_data, free);
// SAFETY: Preconditions delegate to `CBox::from_c`'s safety.
let user_data = unsafe { CBox::from_c(user_data, free) };
let user_data = CArc::wrap(user_data)?;
self.m.user_data = Some(user_data);
Ok(())
Expand Down

0 comments on commit 41b267d

Please sign in to comment.