Author: zoltan
Date: 2007-05-01 11:11:29 -0400 (Tue, 01 May 2007)
New Revision: 76529

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/icall.c
   trunk/mono/mono/metadata/reflection.c
Log:
2007-05-01  Zoltan Varga  <[EMAIL PROTECTED]>

        * icall.c (custom_attrs_get_by_type): Handle loading errors gracefully. 
Fixes
        #81498.

        * reflection.c (mono_reflection_get_custom_attrs_by_type): Handle 
loading errors
        gracefully.
        (mono_custom_attrs_from_index): Ditto.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-05-01 15:06:36 UTC (rev 76528)
+++ trunk/mono/mono/metadata/ChangeLog  2007-05-01 15:11:29 UTC (rev 76529)
@@ -1,5 +1,12 @@
 2007-05-01  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * icall.c (custom_attrs_get_by_type): Handle loading errors gracefully. 
Fixes
+       #81498.
+
+       * reflection.c (mono_reflection_get_custom_attrs_by_type): Handle 
loading errors
+       gracefully.
+       (mono_custom_attrs_from_index): Ditto.
+
        * icall.c (ves_icall_InternalInvoke): Allow calling ctors of abstract 
classes. 
        Fixes #81501.
 

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2007-05-01 15:06:36 UTC (rev 76528)
+++ trunk/mono/mono/metadata/icall.c    2007-05-01 15:11:29 UTC (rev 76529)
@@ -6438,7 +6438,14 @@
 static MonoArray*
 custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type)
 {
-       return mono_reflection_get_custom_attrs_by_type (obj, attr_type ? 
mono_class_from_mono_type (attr_type->type) : NULL);
+       MonoArray *res = mono_reflection_get_custom_attrs_by_type (obj, 
attr_type ? mono_class_from_mono_type (attr_type->type) : NULL);
+
+       if (mono_loader_get_last_error ()) {
+               mono_raise_exception (mono_loader_error_prepare_exception 
(mono_loader_get_last_error ()));
+               g_assert_not_reached ();
+       } else {
+               return res;
+       }
 }
 
 static MonoBoolean

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2007-05-01 15:06:36 UTC (rev 
76528)
+++ trunk/mono/mono/metadata/reflection.c       2007-05-01 15:11:29 UTC (rev 
76529)
@@ -7158,6 +7158,11 @@
        return result;
 }
 
+/**
+ * mono_custom_attrs_from_index:
+ *
+ * Returns: NULL if no attributes are found or if a loading error occurs.
+ */
 MonoCustomAttrInfo*
 mono_custom_attrs_from_index (MonoImage *image, guint32 idx)
 {
@@ -7201,8 +7206,12 @@
                        break;
                }
                ainfo->attrs [i].ctor = mono_get_method (image, mtoken, NULL);
-               if (!ainfo->attrs [i].ctor)
-                       g_error ("Can't find custom attr constructor image: %s 
mtoken: 0x%08x", image->name, mtoken);
+               if (!ainfo->attrs [i].ctor) {
+                       g_warning ("Can't find custom attr constructor image: 
%s mtoken: 0x%08x", image->name, mtoken);
+                       g_list_free (list);
+                       g_free (ainfo);
+                       return NULL;
+               }
                data = mono_metadata_blob_heap (image, cols 
[MONO_CUSTOM_ATTR_VALUE]);
                ainfo->attrs [i].data_size = mono_metadata_decode_value (data, 
&data);
                ainfo->attrs [i].data = (guchar*)data;
@@ -7466,7 +7475,8 @@
  *
  * Return an array with all the custom attributes defined of the
  * reflection handle @obj. If @attr_klass is non-NULL, only custom attributes 
- * of that type are returned. The objects are fully build.
+ * of that type are returned. The objects are fully build. Return NULL if a 
loading error
+ * occurs.
  */
 MonoArray*
 mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass 
*attr_klass)
@@ -7485,6 +7495,8 @@
        } else {
                MonoClass *klass;
                klass = mono_class_from_name (mono_defaults.corlib, "System", 
"Attribute");
+               if (mono_loader_get_last_error ())
+                       return NULL;
                result = mono_array_new (mono_domain_get (), klass, 0);
        }
 
@@ -7496,7 +7508,8 @@
  * @obj: a reflection object handle
  *
  * Return an array with all the custom attributes defined of the
- * reflection handle @obj. The objects are fully build.
+ * reflection handle @obj. The objects are fully build. Return NULL if a 
loading error
+ * occurs.
  */
 MonoArray*
 mono_reflection_get_custom_attrs (MonoObject *obj)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to