Home Dashboard Directory Help
Search

CWnd::CreateIndirect memory leak in VS2005, VS2010, VS2010 SP1 by Andreas Schniertshauer


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 635527
Opened: 1/11/2011 7:26:48 AM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

Hello,

I get the following memory leaks using the function CreateIndirect:

atlmfc\src\mfc\occmgr.cpp(195) : {11291} normal block at 0x01F19748, 104 bytes long.
occmgr.cpp(181) : {10099} normal block at 0x01ED9B88, 56 bytes long.

This memory leak occurs because in my case the creation of the dialog fails and the hWnd in the function CWnd::CreateDlgIndirect (dlgcore.cpp) is zero. But pOccManager->PreCreateDialog was already called so pDlgInfo->m_ppOleDlgItems and pDlgInfo->m_pItemInfo (both in occmgr.cpp) were already allocated but these are not freed because of this code sequence in dlgcore.cpp:

ifndef _AFX_NO_OCC_SUPPORT
    if (pOccManager != NULL)
    {
        if (hWnd != NULL)
        {
            pOccManager->PostCreateDialog(&occDialogInfo);
            SetOccDialogInfo(NULL);
        }
    }
#endif //!_AFX_NO_OCC_SUPPORT

The test for hwnd != NULL appears to be wrong.
Details
Sign in to post a comment.
Posted by Microsoft on 1/14/2011 at 1:24 PM
Hello,

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio.

Pat Brenner
Visual C++ Libraries Development
Posted by Microsoft on 1/11/2011 at 7:15 PM

Thanks for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/11/2011 at 7:58 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.