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

LocalFree returns error on success #2723

Closed
TimMisiak opened this issue Dec 5, 2023 · 1 comment
Closed

LocalFree returns error on success #2723

TimMisiak opened this issue Dec 5, 2023 · 1 comment
Labels
question Further information is requested

Comments

@TimMisiak
Copy link

Summary

Seems like LocalFree has a swapped error/success condition.

Docs say "If the function succeeds, the return value is NULL."

Code for LocalFree has:

#[inline]
pub unsafe fn LocalFree<P0>(hmem: P0) -> ::windows_core::Result<HLOCAL>
where
    P0: ::windows_core::IntoParam<HLOCAL>,
{
    ::windows_targets::link!("kernel32.dll" "system" fn LocalFree(hmem : HLOCAL) -> HLOCAL);
    let result__ = LocalFree(hmem.into_param().abi());
    (!result__.is_invalid()).then(|| result__).ok_or_else(::windows_core::Error::from_win32)
}

And is_invalid for HLOCAL checks for is_null.

Crate manifest

No response

Crate code

No response

@TimMisiak TimMisiak added the bug Something isn't working label Dec 5, 2023
@kennykerr
Copy link
Collaborator

See microsoft/win32metadata#1557

@kennykerr kennykerr added question Further information is requested and removed bug Something isn't working labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants