ATL bug of CComPtr?

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


In the ATL Internals book, one form of constructor of CComQIPtr is implemented as this,

Code:
CComQIPtr (IUnknown* lp)
{
    p = NULL; if (lp != NULL) lp -> QueryInterface (*piid, (void**)&p);
}

I think there is a bug when QueryInterface fails, and the original value of member variable p is overwritten.

I found the in MSVC 2008, the implementation is,

Code:
atlcomcli.h

	CComQIPtr(_In_opt_ IUnknown* lp) throw()
	{
		if (lp != NULL)
			lp->QueryInterface(*piid, (void **)&p);
	}

Seems the bug is fixed? Is it a bug in old version of ATL or a bug in the book? :)


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,785
Messages
2,569,624
Members
45,318
Latest member
LuisWestma

Latest Threads

Top