Fixed a crash on Windows XP and older systems

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1112 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
kode54 2012-08-26 07:44:19 +00:00
parent c8d6432cb7
commit 51afa7e129
2 changed files with 12 additions and 8 deletions

View File

@ -105,7 +105,6 @@ public:
if ( SUCCEEDED( hr ) ) if ( SUCCEEDED( hr ) )
{ {
pEnumerator->RegisterEndpointNotificationCallback( this ); pEnumerator->RegisterEndpointNotificationCallback( this );
registered = true;
} }
} }
@ -118,9 +117,12 @@ public:
{ {
if ( InterlockedDecrement( &registered ) == 0 ) if ( InterlockedDecrement( &registered ) == 0 )
{ {
pEnumerator->UnregisterEndpointNotificationCallback( this ); if (pEnumerator)
pEnumerator->Release(); {
registered = false; pEnumerator->UnregisterEndpointNotificationCallback( this );
pEnumerator->Release();
pEnumerator = NULL;
}
} }
EnterCriticalSection( &lock ); EnterCriticalSection( &lock );

View File

@ -103,7 +103,6 @@ public:
if ( SUCCEEDED( hr ) ) if ( SUCCEEDED( hr ) )
{ {
pEnumerator->RegisterEndpointNotificationCallback( this ); pEnumerator->RegisterEndpointNotificationCallback( this );
registered = true;
} }
} }
@ -116,9 +115,12 @@ public:
{ {
if ( InterlockedDecrement( &registered ) == 0 ) if ( InterlockedDecrement( &registered ) == 0 )
{ {
pEnumerator->UnregisterEndpointNotificationCallback( this ); if (pEnumerator)
pEnumerator->Release(); {
registered = false; pEnumerator->UnregisterEndpointNotificationCallback( this );
pEnumerator->Release();
pEnumerator = NULL;
}
} }
EnterCriticalSection( &lock ); EnterCriticalSection( &lock );