Skip to content

Commit d2fcb23

Browse files
authored
Merge pull request #1342 from Unity-Technologies/unity-master-fix-1274470
Unity master fix case 1274470
2 parents a0defb5 + 6a9232a commit d2fcb23

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

mono/metadata/marshal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6833,10 +6833,12 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
68336833
mono_mb_emit_ldloc (mb, conv_arg);
68346834
break;
68356835

6836-
case MARSHAL_ACTION_CONV_RESULT:
6837-
/* fixme: we need conversions here */
6838-
mono_mb_emit_stloc (mb, 3);
6836+
case MARSHAL_ACTION_CONV_RESULT: {
6837+
mono_mb_emit_byte (mb, CEE_POP);
6838+
char *msg = g_strdup_printf ("Cannot marshal 'return value': Invalid managed/unmanaged type combination.");
6839+
mono_mb_emit_exception_marshal_directive (mb, msg);
68396840
break;
6841+
}
68406842

68416843
case MARSHAL_ACTION_MANAGED_CONV_IN: {
68426844
MonoClass *eklass;

mono/tests/libtest.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7556,3 +7556,12 @@ mono_test_native_to_managed_exception_rethrow (NativeToManagedExceptionRethrowFu
75567556
pthread_join (t, NULL);
75577557
}
75587558
#endif
7559+
7560+
static guint8 static_arr[] = { 1, 2, 3, 4 };
7561+
7562+
LIBTEST_API guint8*
7563+
mono_test_marshal_return_array (void)
7564+
{
7565+
return static_arr;
7566+
}
7567+

mono/tests/pinvoke2.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,5 +1987,17 @@ public static unsafe int test_0_fixed_buffer_unicode () {
19871987
return 2;
19881988
return 0;
19891989
}
1990+
1991+
[DllImport ("libtest", EntryPoint="mono_test_marshal_return_array")]
1992+
public static extern int[] mono_test_marshal_return_array ();
1993+
1994+
public static int test_0_return_array () {
1995+
try {
1996+
var arr = mono_test_marshal_return_array ();
1997+
return 1;
1998+
} catch (MarshalDirectiveException) {
1999+
return 0;
2000+
}
2001+
}
19902002
}
19912003

0 commit comments

Comments
 (0)