Home Dashboard Directory Help

CComApartment::Apartment() leaks objects on edge cases by Dmitry Me


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 742895
Opened: 5/21/2012 3:21:05 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
User(s) can reproduce this bug


Currently atlbase.h contains CComApartment class that has Apartment() member function that has this code:

IUnknown* pUnk = NULL;
pdata->hRes = pdata->pfnCreateInstance(NULL, __uuidof(IUnknown), (void**)&pUnk);
if (SUCCEEDED(pdata->hRes))
    pdata->hRes = CoMarshalInterThreadInterfaceInStream(*pdata->piid, pUnk, &pdata->pStream);
if (SUCCEEDED(pdata->hRes))
ATLTRACE(atlTraceCOM, 2, _T("Object created on thread = %d\n"), GetCurrentThreadId());

Now if pfnCreateInstance() succeeds but CoMarshalInterThreadInterfaceInStream() fails then "Release()" is not called and the object is leaked.
Sign in to post a comment.
Posted by Microsoft on 10/8/2012 at 2:17 PM
Hello Dmitry,

Thank you very much for the feedback. The problem has been fixed in next release of Visual Studio.

Windows C++ Libraries Team
Lukasz Chodorski
Posted by MS-Moderator08 [Feedback Moderator] on 5/22/2012 at 1:04 AM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 5/21/2012 at 3:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.