Skip to content

Commit

Permalink
Use IUnknown::from_raw_borrowed to avoid double free
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Aug 27, 2024
1 parent 6271aa6 commit 7443a52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ impl Variant {
VT_EMPTY => Variant::Empty,
VT_NULL => Variant::Null,
VT_UNKNOWN => {
let ptr = unsafe { IUnknown::from_raw(vt.Anonymous.Anonymous.Anonymous.punkVal) };
Variant::Unknown(IUnknownWrapper::new(ptr.clone()))
let ptr = unsafe { IUnknown::from_raw_borrowed(&vt.Anonymous.Anonymous.Anonymous.punkVal) };
let ptr = ptr.cloned().ok_or(WMIError::NullPointerResult)?;
Variant::Unknown(IUnknownWrapper::new(ptr))
}
_ => return Err(WMIError::ConvertError(variant_type)),
};
Expand Down

0 comments on commit 7443a52

Please sign in to comment.