From fd8a5f9ebfc862d6fcbfea6bfc2b0f2ac5db1a79 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Tue, 7 Mar 2017 10:46:59 +0100 Subject: [PATCH] [interp] throw NRE in mint_vcall insn if receiver is null --- mono/mini/arrays.cs | 1 - mono/mini/interp/interp.c | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mono/mini/arrays.cs b/mono/mini/arrays.cs index b3002716e46..907494a0df6 100644 --- a/mono/mini/arrays.cs +++ b/mono/mini/arrays.cs @@ -318,7 +318,6 @@ class Tests return 0; } - [Category ("!INTERPRETER")] public static int test_0_multi_dimension_arrays () { int sum; diff --git a/mono/mini/interp/interp.c b/mono/mini/interp/interp.c index a86eb609dfc..f87c9b52763 100644 --- a/mono/mini/interp/interp.c +++ b/mono/mini/interp/interp.c @@ -1967,8 +1967,12 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context) child_frame.retval = sp; /* decrement by the actual number of args */ sp -= child_frame.runtime_method->param_count; - if (child_frame.runtime_method->hasthis) + if (child_frame.runtime_method->hasthis) { --sp; + MonoObject *this_arg = sp->data.p; + if (!this_arg) + THROW_EX (mono_get_exception_null_reference(), ip - 2); + } child_frame.stack_args = sp; if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->method->klass->valuetype && mono_object_is_transparent_proxy (sp->data.p)) { -- 2.25.1