2006-05-27 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 27 May 2006 17:09:22 +0000 (17:09 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 27 May 2006 17:09:22 +0000 (17:09 -0000)
* class.c (mono_class_from_typeref): handle missing images
earlier, deals with bug #78418.   Refactor code;

Fix a warning introduced in my previous commit (some stale code
from before I revisited my patch).

svn path=/trunk/mono/; revision=61193

mono/metadata/ChangeLog
mono/metadata/class.c

index 1fe5a848290e203010432b48095d2799c09bc030..83a1be10225fa3046c201bad9bd426b4897983e4 100644 (file)
@@ -1,5 +1,11 @@
 2006-05-27  Miguel de Icaza  <miguel@novell.com>
 
+       * class.c (mono_class_from_typeref): handle missing images
+       earlier, deals with bug #78418.   Refactor code; 
+
+       Fix a warning introduced in my previous commit (some stale code
+       from before I revisited my patch).
+
        * class.c (mono_class_create_from_typedef): On failure, remove the
        class from the MonoImage->class_cache as the class is not
        initialized;   Fixes the leak pointed out by Paolo.
index a1f2ef9ebac3a194d7261c77bd9a039f45aa1a4d..445d78a101b03ca2d6c564b8dd94ac00fec112e6 100644 (file)
@@ -75,7 +75,19 @@ mono_class_from_typeref (MonoImage *image, guint32 type_token)
                /* a typedef in disguise */
                return mono_class_from_name (image, nspace, name);
        case MONO_RESOLTION_SCOPE_MODULEREF:
-               return mono_class_from_name (image->modules [idx - 1], nspace, name);
+               if (image->modules [idx-1])
+                       return mono_class_from_name (image->modules [idx - 1], nspace, name);
+               else {
+                       char *msg = g_strdup_printf ("%s%s%s", nspace, nspace [0] ? "." : "", name);
+                       char *human_name;
+                       
+                       human_name = mono_stringify_assembly_name (&image->assembly->aname);
+                       mono_loader_set_error_type_load (msg, human_name);
+                       g_free (msg);
+                       g_free (human_name);
+               
+                       return NULL;
+               }
        case MONO_RESOLTION_SCOPE_TYPEREF: {
                MonoClass *enclosing = mono_class_from_typeref (image, MONO_TOKEN_TYPE_REF | idx);
                GList *tmp;
@@ -1773,7 +1785,7 @@ mono_class_setup_vtable (MonoClass *class)
 
        mono_loader_unlock ();
 
-       return ok;
+       return;
 }
 
 /*