Originally Posted by
iMalc
I know, I use COM every day at work. Actually I think I've figured it out. It's to do with re-entrancy.
Inside Release, the object's destructor is called if this was the last CComPtr to be holding this object. Now what if for some bizarre reason that object contained a CComPtr to itself, which is what we just called Release on?
First Approach - no problem, during the destructor's call to Release (which is in turn inside the first call to Release) the pointer is already NULL.
Second Approach - Boom! during the destructor's call to Release the refcount gets subtracted again and goes below zero.
Anyway, for both reasons I've stated, Approach 1 is safer.