Merge pull request #4840 from kumpera/unaligned-access
[mono.git] / mono / mini / interp / interp.c
index 68d3b3998a457502b485c9df372cd8aea54b47e9..bea20a44f54c3f8ecc2fc534776564e4720e2e4a 100644 (file)
@@ -3486,10 +3486,13 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CPOBJ) {
                        c = rtm->data_items[* (guint16 *)(ip + 1)];
-                       g_assert (c->byval_arg.type == MONO_TYPE_VALUETYPE);
+                       g_assert (c->valuetype);
                        /* if this assertion fails, we need to add a write barrier */
                        g_assert (!MONO_TYPE_IS_REFERENCE (&c->byval_arg));
-                       stackval_from_data (&c->byval_arg, &sp [-2], sp [-1].data.p, FALSE);
+                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE)
+                               stackval_from_data (&c->byval_arg, &sp [-2], sp [-1].data.p, FALSE);
+                       else
+                               stackval_from_data (&c->byval_arg, sp [-2].data.p, sp [-1].data.p, FALSE);
                        ip += 2;
                        sp -= 2;
                        MINT_IN_BREAK;