Skip to content

Commit bae9eb3

Browse files
committed
Handle assignment check of variant type and its gtd.
* clas.c (mono_class_is_variant_compatible): Return FALSE if checking a variant type and its gtd instead of crashing. Fixes #668506
1 parent 5de92f8 commit bae9eb3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mono/metadata/class.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7201,10 +7201,11 @@ mono_class_is_variant_compatible (MonoClass *klass, MonoClass *oklass)
72017201
int j;
72027202
MonoType **klass_argv, **oklass_argv;
72037203
MonoClass *klass_gtd = mono_class_get_generic_type_definition (klass);
7204+
MonoClass *oklass_gtd = mono_class_get_generic_type_definition (oklass);
72047205
MonoGenericContainer *container = klass_gtd->generic_container;
72057206

72067207
/*Viable candidates are instances of the same generic interface*/
7207-
if (mono_class_get_generic_type_definition (oklass) != klass_gtd)
7208+
if (mono_class_get_generic_type_definition (oklass) != klass_gtd || oklass == klass_gtd)
72087209
return FALSE;
72097210

72107211
klass_argv = &klass->generic_class->context.class_inst->type_argv [0];
@@ -7344,7 +7345,7 @@ mono_class_is_variant_compatible_slow (MonoClass *klass, MonoClass *oklass)
73447345
MonoGenericContainer *container = klass_gtd->generic_container;
73457346

73467347
/*Viable candidates are instances of the same generic interface*/
7347-
if (mono_class_get_generic_type_definition (oklass) != klass_gtd)
7348+
if (mono_class_get_generic_type_definition (oklass) != klass_gtd || oklass == klass_gtd)
73487349
return FALSE;
73497350

73507351
klass_argv = &klass->generic_class->context.class_inst->type_argv [0];

0 commit comments

Comments
 (0)