From b80fb45acb479592be5f0f3595626046ca0a2a80 Mon Sep 17 00:00:00 2001 From: Bill Holmes Date: Mon, 16 Aug 2021 14:59:17 -0400 Subject: [PATCH] Adding null check to avoid abort when invalid IL is encountered When a callvirt instruction is encountered on a static method, there is a hard abort/crash. This commit avoids the problem. --- src/mono/mono/mini/method-to-ir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index 5b607e55636ea..5d17be0c34a7d 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -7314,7 +7314,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b sp -= n; - if (virtual_ && cmethod && sp [0]->opcode == OP_TYPED_OBJREF) { + if (virtual_ && cmethod && sp [0] && sp [0]->opcode == OP_TYPED_OBJREF) { ERROR_DECL (error); MonoMethod *new_cmethod = mono_class_get_virtual_method (sp [0]->klass, cmethod, error);