Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This blog post has moved to https://matthewvaneerde.wordpress.com/2008/05/27/spot-the-bug-imfoutputschema/
Comments
Anonymous
June 09, 2008
Without much review, I am thinking QueryInterface should initialize m_cRefCount. It does not appear that the private reference count is every properly initialized.Anonymous
June 16, 2008
Bingo. I fixed this by updating the initializer list in the constructor: // constructor CTrustedAudioDriversOutputSchema::CTrustedAudioDriversOutputSchema( DWORD dwConfigData, GUID guidOriginatorID ) : m_cRefCount(1) , m_dwConfigData(dwConfigData) , m_guidOriginatorID(guidOriginatorID) {} There's more than one way to do refcount initialization. I could equally well have initialized the refcount to 0 and done an AddRef() in the factory function. When I ran under the debugger, the debugger initialized m_cRefCount with garbage memory, so the refcount never dropped to zero; when I ran outside of the debugger, m_cRefCount was initialized to 0, so the "delete this;" in Release() was called one Release() too soon.