Permalink
Browse files

Fix infinite loop in mono_class_get_nested_types () if a nested type …

…fails to load. Fixes # 630041. Add a test.
  • Loading branch information...
1 parent c573988 commit 8d84837615597e5426859f5f184b3d1c6ef5384b @vargaz vargaz committed Aug 12, 2010
Showing with 16 additions and 1 deletion.
  1. +4 −1 mono/metadata/class.c
  2. +11 −0 mono/tests/load-exceptions.cs
  3. +1 −0 mono/tests/t-missing.cs
View
@@ -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);
@@ -9,6 +9,11 @@
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 static int test_0_bad_method_override4 ()
}
#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));
}
View
@@ -25,6 +25,7 @@ public class Foo2 {
#endif
}
+
public class Foo3 {
#if FOUND
public static int i;

0 comments on commit 8d84837

Please sign in to comment.