Home Dashboard Directory Help
Search

_com_error incorrectly frees memory with HeapFree instead of LocalFree by Jochen Kalmbach


Status: 

Closed
 as Fixed Help for as Fixed


0
0
Sign in
to vote
Type: Bug
ID: 466042
Opened: 6/10/2009 12:33:45 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

_com_error internaly uses "FormatMessage" with "FORMAT_MESSAGE_ALLOCATE_BUFFER" to get the error message for a specific error code.
If "FormatMessage" allocates the memory of the string, the called (in this case _com_error) must free this memory with "LocalFree". But the destructor frees the memory with "HeapFree" with the process heap. This is wrong and causes in memory-checking tools errors.
Until VS2003 then behavior was correct. The problem appears starting with VS2005.

See also previous bug in VS2008:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=339034

(It was promised to be solved in VS2008 SP1...)
Details
Sign in to post a comment.
Posted by Microsoft on 6/12/2009 at 4:26 PM
Hello,

Thanks for the report. This has now been fixed for Visual Studio 2010. The fix was originally added to Visual Studio 2008 SP1 and was accidentally not ported over to 2010.

Pat Brenner
Visual C++ Libraries Development
Posted by Microsoft on 6/11/2009 at 10:11 PM
Thanks for your feedback.

We are escalating 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.
Sign in to post a workaround.