Skip to content

Possible bug with DECIMAL type in VARIANT #2876

@hcldan

Description

@hcldan

Summary

I've been looking around at supporting VARIANT.

I had a bit of trouble but found a good way to deal with BSTR. It contains a pointer in mem and therefore the VARIANT_0_0_0 member for it is a ManuallyDrop

Anonymous: VARIANT_0_0_0 {
  bstrVal: ManuallyDrop::new(
    // When made this way, the BSTR will have memory created in windows
    // so we don't have to maintain a ref to the original data.
    match BSTR::from_wide(&value) {
      Ok(b) => b,
      Err(err) => return Err(err),
    }
  ),
},

You can see that in the drop for BSTR the memory is deallocated from windows.

I started looking at DECIMAL support in VARIANT_0_0_0 and it looks like it takes a pointer to a DECIMAL

I would have expected it to take some kind of ManuallyDrop<DECIMAL_WRAPPER> that surrounds a pointer to the innards.
If I get a VARIANT of this type as a result of a COM call, do I need to worry about the pointer to the DECIMAL? Who owns that memory? How does it get cleaned up?

Crate manifest

No response

Crate code

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions