Handle assignment check of variant type and its gtd.
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 9 Feb 2011 15:30:05 +0000 (16:30 +0100)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 9 Feb 2011 15:31:28 +0000 (16:31 +0100)
* clas.c (mono_class_is_variant_compatible): Return
FALSE if checking a variant type and its gtd instead
of crashing.

Fixes #668506

mono/metadata/class.c

index bca527e1b5dc0b364099ad18da0202eed76aa5d5..76ba74547bf4fd2a3fa99cecb954dfc0d3cbe532 100644 (file)
@@ -7201,10 +7201,11 @@ mono_class_is_variant_compatible (MonoClass *klass, MonoClass *oklass)
        int j;
        MonoType **klass_argv, **oklass_argv;
        MonoClass *klass_gtd = mono_class_get_generic_type_definition (klass);
+       MonoClass *oklass_gtd = mono_class_get_generic_type_definition (oklass);
        MonoGenericContainer *container = klass_gtd->generic_container;
 
        /*Viable candidates are instances of the same generic interface*/
-       if (mono_class_get_generic_type_definition (oklass) != klass_gtd)
+       if (mono_class_get_generic_type_definition (oklass) != klass_gtd || oklass == klass_gtd)
                return FALSE;
 
        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)
        MonoGenericContainer *container = klass_gtd->generic_container;
 
        /*Viable candidates are instances of the same generic interface*/
-       if (mono_class_get_generic_type_definition (oklass) != klass_gtd)
+       if (mono_class_get_generic_type_definition (oklass) != klass_gtd || oklass == klass_gtd)
                return FALSE;
 
        klass_argv = &klass->generic_class->context.class_inst->type_argv [0];