diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index 37c0093fa..feaf80243 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -665,6 +665,11 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) ASSERTA(a); ASSERTA(B); { auto o = (DObject*)reg.a[B]; + if (o == nullptr) + { + ThrowAbortException(X_READ_NIL, nullptr); + return 0; + } auto p = o->GetClass(); assert(C < p->Virtuals.Size()); reg.a[a] = p->Virtuals[C]; @@ -673,7 +678,13 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) OP(SCOPE): { ASSERTA(a); ASSERTKA(C); - FScopeBarrier::ValidateCall(((DObject*)reg.a[a])->GetClass(), (VMFunction*)konsta[C].v, B - 1); + auto o = (DObject*)reg.a[a]; + if (o == nullptr) + { + ThrowAbortException(X_READ_NIL, nullptr); + return 0; + } + FScopeBarrier::ValidateCall(o->GetClass(), (VMFunction*)konsta[C].v, B - 1); } NEXTOP;