ATL bug of CComPtr?

Discussion in 'C Programming' started by George2, Apr 7, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    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
     
    George2, Apr 7, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sunil George
    Replies:
    1
    Views:
    3,129
    Dmitriy Lapshin [C# / .NET MVP]
    Aug 6, 2003
  2. Tarundeep Singh Kalra

    could not start ASP.NET or ATL Server Debugging

    Tarundeep Singh Kalra, Apr 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    7,517
    Tarundeep Singh Kalra
    Apr 13, 2004
  3. Dmitry
    Replies:
    0
    Views:
    814
    Dmitry
    Nov 1, 2004
  4. WTH
    Replies:
    1
    Views:
    458
  5. George2

    CComPtr

    George2, Apr 3, 2008, in forum: C Programming
    Replies:
    0
    Views:
    509
    George2
    Apr 3, 2008
Loading...

Share This Page