Skip to content

Commit

Permalink
To be safe, clone and leak the BSTR
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Aug 27, 2024
1 parent 7443a52 commit 6bfcdda
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ impl Variant {
let variant_value = match VARENUM(variant_type) {
VT_BSTR => {
let bstr_ptr = unsafe { BSTR::from_raw(vt.Anonymous.Anonymous.Anonymous.bstrVal) };
Variant::String(bstr_ptr.try_into()?)
let bstr_as_str = bstr_ptr.to_string();
// We don't want to be the ones freeing the BSTR.
let _ = bstr_ptr.into_raw();
Variant::String(bstr_as_str)
}
VT_I1 => {
let num = unsafe { vt.Anonymous.Anonymous.Anonymous.cVal };
Expand Down

0 comments on commit 6bfcdda

Please sign in to comment.