Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,8 @@ create_runtime_invoke_info (MonoMethod *method, gpointer compiled_method, gboole
return ret;
}

static GENERATE_GET_CLASS_WITH_CACHE (nullbyrefreturn_ex, "Mono", "NullByRefReturnException");

static MonoObject*
mono_llvmonly_runtime_invoke (MonoMethod *method, RuntimeInvokeInfo *info, void *obj, void **params, MonoObject **exc, MonoError *error)
{
Expand Down Expand Up @@ -3127,11 +3129,29 @@ mono_llvmonly_runtime_invoke (MonoMethod *method, RuntimeInvokeInfo *info, void
if (exc && *exc)
return NULL;

if (sig->ret->byref) {
if (*(gpointer*)retval == NULL) {
MonoClass *klass = mono_class_get_nullbyrefreturn_ex_class ();
MonoObject *ex = mono_object_new_checked (klass, error);
mono_error_assert_ok (error);
mono_error_set_exception_instance (error, (MonoException*)ex);
return NULL;
}
}

if (sig->ret->type != MONO_TYPE_VOID) {
if (info->ret_box_class)
return mono_value_box_checked (info->ret_box_class, retval, error);
else
return *(MonoObject**)retval;
if (info->ret_box_class) {
if (sig->ret->byref) {
return mono_value_box_checked (info->ret_box_class, *(gpointer*)retval, error);
} else {
return mono_value_box_checked (info->ret_box_class, retval, error);
}
} else {
if (sig->ret->byref)
return **(MonoObject***)retval;
else
return *(MonoObject**)retval;
}
} else {
return NULL;
}
Expand Down