Add null checks before calling ClassLoader::EnsureLoaded (dotnet/coreclr#24818)
authorJan Kotas <jkotas@microsoft.com>
Wed, 29 May 2019 01:38:42 +0000 (18:38 -0700)
committerGitHub <noreply@github.com>
Wed, 29 May 2019 01:38:42 +0000 (18:38 -0700)
Fixes dotnet/coreclr#24816

Commit migrated from https://github.com/dotnet/coreclr/commit/02e75ab55272902aed4c2501ab7c6740bae30485

src/coreclr/src/vm/fieldmarshaler.h

index 1718bd3..7041cf1 100644 (file)
@@ -447,7 +447,9 @@ protected:
         Module::RestoreMethodTablePointer(ppMT);
 #else // FEATURE_PREJIT
         // without NGEN we only have to make sure that the type is fully loaded
-        ClassLoader::EnsureLoaded(ppMT->GetValue());
+        MethodTable* pMT = ppMT->GetValue();
+        if (pMT != NULL)
+            ClassLoader::EnsureLoaded(pMT);
 #endif // FEATURE_PREJIT
     }
 
@@ -1094,7 +1096,9 @@ public:
         Module::RestoreTypeHandlePointer(&m_arrayType);
 #else // FEATURE_PREJIT
         // without NGEN we only have to make sure that the type is fully loaded
-        ClassLoader::EnsureLoaded(m_arrayType.GetValue());
+        TypeHandle th = m_arrayType.GetValue();
+        if (!th.IsNull())
+            ClassLoader::EnsureLoaded(th);
 #endif // FEATURE_PREJIT
         FieldMarshaler::RestoreImpl();
     }