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

Windows CoUninitialize() should only be called if CoInitializeEx() succeeded #53

Closed
btzy opened this issue Aug 11, 2018 · 1 comment
Closed
Assignees

Comments

@btzy
Copy link

btzy commented Aug 11, 2018

Lines 369-373 of nfd_win.cpp (using devel branch):

if ( !SUCCEEDED(result))
{
    NFDi_SetError("Could not initialize COM.");
    goto end;
}

In the existing implementation, the above code is executed when CoInitializeEx() fails. end is where CoUninitialize() is called. Calling CoUninitialize() if CoInitializeEx() fails is wrong, according to the MSDN documentation:

To close the COM library gracefully on a thread, each successful call to CoInitialize or CoInitializeEx, including any call that returns S_FALSE, must be balanced by a corresponding call to CoUninitialize.

So we shouldn't be calling CoUninitialize() if it CoInitializeEx() does not succeed.

@mlabbe mlabbe self-assigned this Dec 30, 2018
@mlabbe
Copy link
Owner

mlabbe commented Dec 31, 2018

Fixed in f055c30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants