Fix infinite loop in mono_class_get_nested_types () if a nested type fails to load...
authorZoltan Varga <vargaz@gmail.com>
Thu, 12 Aug 2010 00:36:26 +0000 (02:36 +0200)
committerZoltan Varga <vargaz@gmail.com>
Thu, 12 Aug 2010 00:37:23 +0000 (02:37 +0200)
mono/metadata/class.c
mono/tests/load-exceptions.cs
mono/tests/t-missing.cs

index db5e0177164dfd0f377be98ad603baffb4916ddc..4b61fb8b54a662f10c509751ee0d57b0b68f99a0 100644 (file)
@@ -8063,8 +8063,11 @@ mono_class_get_nested_types (MonoClass* klass, gpointer *iter)
                                guint32 cols [MONO_NESTED_CLASS_SIZE];
                                mono_metadata_decode_row (&klass->image->tables [MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
                                nclass = mono_class_create_from_typedef (klass->image, MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED]);
-                               if (!nclass)
+                               if (!nclass) {
+                                       mono_loader_clear_error ();
+                                       i = mono_metadata_nesting_typedef (klass->image, klass->type_token, i + 1);
                                        continue;
+                               }
                                mono_class_alloc_ext (klass);
                                klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, nclass);
 
index 13b75de6da12fc5ea6fd760803c2425744671e9e..0c3f5146766f3f47cec68eb1df1f75017eb9b3cb 100644 (file)
@@ -9,6 +9,11 @@ using System.Reflection;
 class Miss1 : Missing.Foo1 {
 }
 
+public class Miss2 {
+       public class Foo : Missing.Foo1 {
+       }
+}
+
 public class Tests : LoadMissing {
 
        public delegate void TestDel ();
@@ -314,6 +319,12 @@ public class Tests : LoadMissing {
        }
 #endif
 
+       public static int test_0_missing_nested () {
+               if (typeof (Miss2).GetNestedTypes ().Length != 0)
+                       return 1;
+               return 0;
+       }
+
        public static int Main () {
                return TestDriver.RunTests (typeof (Tests));
        }
index e594b3e7c21343d2c7f99bfcce5f33d144795da9..dbdd53cfc67d292c43de08958f35721947dda489 100644 (file)
@@ -25,6 +25,7 @@ public class Foo2 {
 #endif
 }
 
+
 public class Foo3 {
 #if FOUND
        public static int i;