Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug with DECIMAL type in VARIANT #2876

Closed
hcldan opened this issue Feb 23, 2024 · 4 comments
Closed

Possible bug with DECIMAL type in VARIANT #2876

hcldan opened this issue Feb 23, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@hcldan
Copy link

hcldan commented Feb 23, 2024

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

@hcldan hcldan added the bug Something isn't working label Feb 23, 2024
@kennykerr kennykerr added question Further information is requested and removed bug Something isn't working labels Feb 24, 2024
@kennykerr
Copy link
Collaborator

Did you try windows 0.53? It has improved VARIANT support.

https://github.com/microsoft/windows-rs/releases/tag/0.53.0

#2786
#2788

BSTR is directly supported and we could add support for DECIMAL if desired.

@kennykerr kennykerr added enhancement New feature or request and removed question Further information is requested labels Feb 24, 2024
@hcldan
Copy link
Author

hcldan commented Feb 26, 2024

Oh my... 0.53 is a really hefty change to what we've been using.
I'll have to look into this. Are there notes on migrating?

I can't seem to figure out how to get my IDispatch out of the VARIANT now...

@hcldan
Copy link
Author

hcldan commented Feb 26, 2024

Well... @kennykerr, I already had support for converting all of the various VT_* types.
The 0.53.0 update, or anything beyond, will be impossible for me to start using until you deliver support for all remaining types.

@kennykerr
Copy link
Collaborator

Let's keep the conversation in one place. Closing as duplicate of #2877.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants