Skip to content

Commit

Permalink
Adding null check to avoid abort when invalid IL is encountered (#57522)
Browse files Browse the repository at this point in the history
When a callvirt instruction is encountered on a static method, there is
a hard abort/crash. This commit avoids the problem.
  • Loading branch information
bholmes committed Aug 19, 2021
1 parent d367827 commit 1ea615c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1ea615c

Please sign in to comment.