Skip to content

Commit

Permalink
Run class cctor in RuntimeHelpers.GetUninitializedObject(type).
Browse files Browse the repository at this point in the history
  • Loading branch information
vargaz committed Nov 18, 2020
1 parent a60137c commit 4cfe89f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ MonoObjectHandle
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectInternal (MonoType *handle, MonoError *error)
{
MonoClass *klass;
MonoVTable *vtable;

g_assert (handle);

Expand Down Expand Up @@ -1401,6 +1402,12 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectI
return NULL_HANDLE;
}

vtable = mono_class_vtable_checked (mono_domain_get (), klass, error);
return_val_if_nok (error, NULL_HANDLE);

mono_runtime_class_init_full (vtable, error);
return_val_if_nok (error, NULL_HANDLE);

if (m_class_is_nullable (klass))
return mono_object_new_handle (mono_domain_get (), m_class_get_nullable_elem_class (klass), error);
else
Expand Down

0 comments on commit 4cfe89f

Please sign in to comment.