Fix leaking ICorProfilerCallback10. (#41791)
authorMikhail Pilin <ww898@users.noreply.github.com>
Thu, 3 Sep 2020 22:02:58 +0000 (00:02 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Sep 2020 22:02:58 +0000 (15:02 -0700)
src/coreclr/src/vm/eetoprofinterfaceimpl.cpp

index 698dbec..3380865 100644 (file)
@@ -658,6 +658,8 @@ HRESULT EEToProfInterfaceImpl::CreateProfiler(
     m_hmodProfilerDLL = hmodProfilerDLL.Extract();
     hmodProfilerDLL = NULL;
 
+    // ATTENTION: Please update EEToProfInterfaceImpl::~EEToProfInterfaceImpl() after adding the next ICorProfilerCallback interface here !!!
+
     // The profiler may optionally support ICorProfilerCallback3,4,5,6,7,8,9,10.  Let's check.
     ReleaseHolder<ICorProfilerCallback10> pCallback10;
     hr = m_pCallback2->QueryInterface(
@@ -904,6 +906,12 @@ EEToProfInterfaceImpl::~EEToProfInterfaceImpl()
             m_pCallback9 = NULL;
         }
 
+        if (m_pCallback10 != NULL)
+        {
+            m_pCallback10->Release();
+            m_pCallback10 = NULL;
+        }
+
         // Only unload the V4 profiler if this is not part of shutdown.  This protects
         // Whidbey profilers that aren't used to being FreeLibrary'd.
         if (fIsV4Profiler && !g_fEEShutDown)