Skip to content

GetAppLocalTempDirectory leaks a RoInitialize call #1333

@kithymel

Description

@kithymel

In Microsoft::Applications::Events::GetAppLocalTempDirectory (lib/utils/utils.cpp), we have this block of code:

auto hr = RoInitialize(RO_INIT_MULTITHREADED) /* Ignoring result from call toRoInitialize as either initialzation is successful, or else already * initialized and it should be ok to proceed in both the scenarios */ UNREFERENCED_PARAMETER(hr);

If you call RoInitialize without a matching call to RoUninitialize, you leak the com initialization on this thread. See the guidance at https://learn.microsoft.com/en-us/windows/win32/api/roapi/nf-roapi-roinitialize:

Each successful call to RoInitialize, including those that return S_FALSE, must be balanced by a corresponding call to RoUninitialize.

This is caught by Application Verifier as AVRF_STOP_THREADPOOL_DIRTY_COM_STATE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions