Author: zoltan
Date: 2006-05-17 12:56:24 -0400 (Wed, 17 May 2006)
New Revision: 60789
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/marshal.c
Log:
2006-05-17 Zoltan Varga <[EMAIL PROTECTED]>
* marshal.c
(ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure):
Applied a patch from kangaroo to fix #77523.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2006-05-17 16:33:42 UTC (rev 60788)
+++ trunk/mono/mono/metadata/ChangeLog 2006-05-17 16:56:24 UTC (rev 60789)
@@ -1,3 +1,8 @@
+2006-05-17 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * marshal.c
(ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure):
+ Applied a patch from kangaroo to fix #77523.
+
2006-05-17 Martin Baulig <[EMAIL PROTECTED]>
* threads.c
Modified: trunk/mono/mono/metadata/marshal.c
===================================================================
--- trunk/mono/mono/metadata/marshal.c 2006-05-17 16:33:42 UTC (rev 60788)
+++ trunk/mono/mono/metadata/marshal.c 2006-05-17 16:56:24 UTC (rev 60789)
@@ -8015,23 +8015,45 @@
mono_runtime_invoke (method, NULL, pa, NULL);
}
-void
-ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (gpointer src,
MonoObject *dst)
+static void
+ptr_to_structure (gpointer src, MonoObject *dst)
{
MonoMethod *method;
gpointer pa [2];
+ method = mono_marshal_get_ptr_to_struct (dst->vtable->klass);
+
+ pa [0] = &src;
+ pa [1] = dst;
+
+ mono_runtime_invoke (method, NULL, pa, NULL);
+}
+
+void
+ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (gpointer src,
MonoObject *dst)
+{
+ MonoType *t;
+
MONO_ARCH_SAVE_REGS;
MONO_CHECK_ARG_NULL (src);
MONO_CHECK_ARG_NULL (dst);
+
+ t = mono_type_get_underlying_type (mono_class_get_type
(dst->vtable->klass));
- method = mono_marshal_get_ptr_to_struct (dst->vtable->klass);
+ if (t->type == MONO_TYPE_VALUETYPE) {
+ MonoException *exc;
+ gchar *tmp;
- pa [0] = &src;
- pa [1] = dst;
+ tmp = g_strdup_printf ("Destination is a boxed value type.");
+ exc = mono_get_exception_argument ("dst", tmp);
+ g_free (tmp);
- mono_runtime_invoke (method, NULL, pa, NULL);
+ mono_raise_exception (exc);
+ return;
+ }
+
+ ptr_to_structure (src, dst);
}
MonoObject *
@@ -8047,7 +8069,7 @@
res = mono_object_new (domain, mono_class_from_mono_type (type->type));
- ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (src,
res);
+ ptr_to_structure (src, res);
return res;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches