Avoid dereferencing null if the debugger APIs are called before initializing the...
authorAndrew Au <andrewau@microsoft.com>
Tue, 6 Dec 2022 18:23:13 +0000 (10:23 -0800)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2022 18:23:13 +0000 (10:23 -0800)
src/coreclr/debug/daccess/dacdbiimpl.cpp
src/coreclr/debug/daccess/dacimpl.h

index 1e356b643a8b4691f83787591e18586ce29a0737..a247641530a536a0e624973d62a45b3384b63a9f 100644 (file)
@@ -4479,6 +4479,11 @@ void  DacDbiInterfaceImpl::EnumerateAssembliesInAppDomain(
     // See comment in code:DacDbiInterfaceImpl::EnumerateModulesInAssembly code for details.
     AppDomain * pAppDomain = vmAppDomain.GetDacPtr();
 
+    if (pAppDomain == nullptr)
+    {
+        return;
+    }
+
     // Pass the magical flags to the loader enumerator to get all Execution-only assemblies.
     iterator = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoading | kIncludeLoaded | kIncludeExecution));
     CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly;
index a122d4eb6758cfa50ce65c5e5bfcb8c3d2c6f0ce..de5b23e0d5e8b046e68791e01297081431bbc099 100644 (file)
@@ -519,6 +519,11 @@ struct ProcessModIter
         {
             m_nextDomain = false;
 
+            if (AppDomain::GetCurrentDomain() == nullptr)
+            {
+                return NULL;
+            }
+
             m_assemIter = AppDomain::GetCurrentDomain()->IterateAssembliesEx((AssemblyIterationFlags)(
                 kIncludeLoaded | kIncludeExecution));
         }