[netcore] Throw the correct exception for byref returns returning null, .net core...
authorZoltan Varga <vargaz@gmail.com>
Tue, 23 Apr 2019 16:05:50 +0000 (12:05 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Apr 2019 16:05:50 +0000 (12:05 -0400)
Commit migrated from https://github.com/mono/mono/commit/c1c7a739cc5e83690350cf209e4c48e6b1e6cdf0

src/mono/mono/metadata/marshal-ilgen.c

index 31f9e9c..c24db28 100644 (file)
@@ -1485,7 +1485,16 @@ handle_enum:
        }
 
        if (sig->ret->byref) {
+               int pos;
+
                /* perform indirect load and return by value */
+#ifdef ENABLE_NETCORE
+               mono_mb_emit_byte (mb, CEE_DUP);
+               pos = mono_mb_emit_branch (mb, CEE_BRTRUE);
+               mono_mb_emit_exception_full (mb, "Mono", "NullByRefReturnException", NULL);
+               mono_mb_patch_branch (mb, pos);
+#endif
+
                int ldind_op;
                MonoType* ret_byval = m_class_get_byval_arg (mono_class_from_mono_type_internal (sig->ret));
                g_assert (!ret_byval->byref);