Here's a bug I've seen today. We had the following code:
HRESULT get_Value( VARIANT* pValue)
{
*pValue = m_vValue; // m_vValue is _variant_t
}
Now, we hoped m_vValue will get copied to *pValue, however it doesn't. Actually it gets copied, but member-copy only, so if you have the variant as VT_BSTR the string won't have its contents copied but only a pointer to it. Now, the correct code is:
VariantCopy( pValue, &m_vValue);