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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 635527 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 1/11/2011 7:26:48 AM
Access Restriction Public



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:

    if (pOccManager != NULL)
        if (hWnd != NULL)

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

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(