- added missing null pointer checks to VM ops

This commit is contained in:
alexey.lysiuk 2018-07-16 17:10:47 +03:00
parent 79b3c41677
commit b2697a99f8
1 changed files with 12 additions and 1 deletions

View File

@ -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;