Suspicious error handling code in CAtlExeModuleT::StartMonitor() - by Dmitry Me

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.


1
0
Sign in
to vote
ID 714802 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/20/2011 1:32:23 AM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

This behavior is observed in version 10.0.40219.1 SP1Rel

atlbase.h contains this code in CAtlExeModuleT

HANDLE StartMonitor() throw()
{
	m_hEventShutdown = ::CreateEvent(NULL, false, false, NULL);
	if (m_hEventShutdown == NULL)
	{
		return NULL;
	}
	DWORD dwThreadID;
	HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
	if(hThread==NULL)
	{
		::CloseHandle(m_hEventShutdown);
	}
	return hThread;
}

Note the "if(hThread==NULL)" branch - the handle is closed, but the member variable is not set to null. This is likely an error - the handle should be set to null once closed to avoid accidential double close. If the code is actually okay then a comment explaining the idea behind the code is needed.
Sign in to post a comment.
Posted by MS-Moderator08 [Feedback Moderator] on 12/21/2011 at 6:57 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 12/20/2011 at 1: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)