Skip to content

Commit

Permalink
Fix unsoundness in PdInfo::as_struct()
Browse files Browse the repository at this point in the history
  • Loading branch information
Sympatron committed Sep 28, 2024
1 parent 246a910 commit 7062a36
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libosdp/src/pdinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,11 @@ impl PdInfoBuilder {
impl PdInfo {
/// Get a C-repr struct for PdInfo that LibOSDP can operate on.
pub fn as_struct(&mut self) -> libosdp_sys::osdp_pd_info_t {
let scbk;
if let Some(key) = self.scbk.as_mut() {
scbk = key.as_mut_ptr();
let scbk = if let Some(key) = self.scbk {
Box::into_raw(Box::new(key)) as *mut _
} else {
scbk = std::ptr::null_mut::<u8>();
}
std::ptr::null_mut::<u8>()
};
libosdp_sys::osdp_pd_info_t {
name: self.name.as_ptr(),
baud_rate: self.baud_rate,
Expand Down

0 comments on commit 7062a36

Please sign in to comment.