An ATL-based application may unexpectedly close when the ATL project redefines the HeapAlloc function in Visual C++ 2005 (907289)



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition

SYMPTOMS

Consider the following scenario. You create a Microsoft Active Template Library (ATL) project in Microsoft Visual C++ 2005. The ATL project redefines the HeapAlloc function to redirect to a different custom function. In this scenario, the ATL application may unexpectedly close.

You may experience this problem when you use a line of code that is similar to the following:
#define HeapAlloc MyHeapAllocator
Note This problem may also occur when you use the HeapCreate, HeapDestroy, HeapFree, and HeapReAlloc functions.

CAUSE

This problem occurs because the ATL feature in Visual Studio 2005 undefined the definitions for some memory management functions, such as the HeapAlloc function. The following line of code is in the ATL header files and undefines a custom definition of HeapAlloc:
#undef HeapAlloc

WORKAROUND

To work around this problem, make sure that you include the ATL header files before you include a custom definition for the HeapAlloc function.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information about ATL features in Visual Studio 2005, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:3/1/2006
Keywords:kbtshoot kbnofix kbinfo kbprb KB907289 kbAudDeveloper