All pastes #41051 Raw Edit

Miscellany

public text v1 · immutable
#41051 ·published 2006-02-10 21:08 UTC
rendered paste body
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 56768)
+++ ChangeLog   (working copy)
@@ -1,3 +1,11 @@
+2006-02-10  Geoff Norton  <gnorton@customerdna.com>
+
+       * marshal.c (mono_marshal_asany): Avoid trying to unbox explicitly laid 
+       out classes.  Fixes #77524
+       * marshal.c (ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure):
+       If the destination object is a boxed structure we should throw 
+       an ArgumentException.  Fixes #77523.
+
 2006-02-09  Dick Porter  <dick@ximian.com>
 
        * threads.c (mono_thread_detach): Drop a reference to the thread
Index: marshal.c
===================================================================
--- marshal.c   (revision 56768)
+++ marshal.c   (working copy)
@@ -7869,7 +7869,19 @@
 
        MONO_CHECK_ARG_NULL (src);
        MONO_CHECK_ARG_NULL (dst);
+       
+       if (dst->vtable->klass->valuetype) {
+               MonoException *exc;
+               gchar *tmp;
 
+               tmp = g_strdup_printf ("Destination is a boxed value type.");
+               exc = mono_get_exception_argument ("dst", tmp);
+               g_free (tmp);  
+
+               mono_raise_exception (exc);
+               return;
+       }
+
        method = mono_marshal_get_ptr_to_struct (dst->vtable->klass);
 
        pa [0] = &src;
@@ -8438,8 +8450,8 @@
                if ((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_AUTO_LAYOUT)
                        break;
 
-               if (((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) ||
-                       klass->blittable || klass->enumtype)
+               if (klass->valuetype && (((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) ||
+                       klass->blittable || klass->enumtype))
                        return mono_object_unbox (o);
 
                res = mono_marshal_alloc (mono_class_native_size (klass, NULL));