[runtime] Avoid calling mono_class_from_mono_type () for sre arrays, it could initial...
authorZoltan Varga <vargaz@gmail.com>
Wed, 31 May 2017 17:21:10 +0000 (13:21 -0400)
committerGitHub <noreply@github.com>
Wed, 31 May 2017 17:21:10 +0000 (13:21 -0400)
mono/metadata/sre.c

index b50434bc1feca744de19cc559bf63b873dac06d3..47dd369faf6f1e608c4f9f79dc95de23364ac246 100644 (file)
@@ -1650,10 +1650,18 @@ mono_reflection_type_handle_mono_type (MonoReflectionTypeHandle ref, MonoError *
                        goto leave;
                g_assert (base);
                gint32 rank = MONO_HANDLE_GETVAL (sre_array, rank);
-               if (rank == 0) //single dimentional array
-                       result = &mono_array_class_get (mono_class_from_mono_type (base), 1)->byval_arg;
-               else
-                       result = &mono_bounded_array_class_get (mono_class_from_mono_type (base), rank, TRUE)->byval_arg;
+               MonoClass *eclass = mono_class_from_mono_type (base);
+               result = mono_image_new0 (eclass->image, MonoType, 1);
+               if (rank == 0)  {
+                       result->type = MONO_TYPE_SZARRAY;
+                       result->data.klass = eclass;
+               } else {
+                       MonoArrayType *at = (MonoArrayType *)mono_image_alloc0 (eclass->image, sizeof (MonoArrayType));
+                       result->type = MONO_TYPE_ARRAY;
+                       result->data.array = at;
+                       at->eklass = eclass;
+                       at->rank = rank;
+               }
                MONO_HANDLE_SETVAL (ref, type, MonoType*, result);
        } else if (is_sre_byref (klass)) {
                MonoReflectionDerivedTypeHandle sre_byref = MONO_HANDLE_CAST (MonoReflectionDerivedType, ref);