-
Notifications
You must be signed in to change notification settings - Fork 493
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
LocalFree returns an Err when it succeeds #2888
Comments
|
Oh I read that too fast, that's in the crate! 😅 |
This is a recurring issue. It boils down to a messy state of affairs in how certain APIs (including this one) are represented in metadata. 0.53.0 of [DllImport("KERNEL32.dll", ExactSpelling = true, PreserveSig = false, SetLastError = true)]
[CanReturnErrorsAsSuccess]
public static extern HLOCAL LocalFree([Optional][In] HLOCAL hMem);
I haven't investigated whether This specific issue could be addressed here, but I feel that moving the metadata attributes closer to SAL annotations (instead of inventing new ones) would benefit everyone in the long run. I'm equally confident that this won't be met with a lot of enthusiasm. |
See #2889 |
|
I'm not clear on what |
Thanks for your help everyone. @kennykerr I suspect Cheers |
Summary
As per the docs for LocalFree:
However, the implementation of
LocalFree
via the crate fails if the return value is a null pointer as shown below:Where
is_invalid
is defined as follows onHLOCAL
:See an example below 😄
Crate manifest
Crate code
Output is as follows:
Also notice the message from
GetLastError
is"The operation completed successfully."
😄Using
MyLocalFree
confirms thatLocalFree
is in fact succeeding with a NULL pointer being returned:Just because I doubted myself so much, I even ensured that memory was correctly being cleared via Task Manager while having the operation run over and over:
Commenting out the
LocalFree
call leaks memory as expected.The text was updated successfully, but these errors were encountered: