mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
Added check for nullptr to CLSS and META instructions of scripting VM
https://forum.zdoom.org/viewtopic.php?t=56667
This commit is contained in:
parent
0c90253a5d
commit
62bac1d612
1 changed files with 12 additions and 2 deletions
|
@ -37,6 +37,16 @@
|
|||
#error vmexec.h must not be #included outside vmexec.cpp. Use vm.h instead.
|
||||
#endif
|
||||
|
||||
static PClass* GetClass(void* ptr)
|
||||
{
|
||||
if (nullptr == ptr)
|
||||
{
|
||||
ThrowAbortException(X_READ_NIL, nullptr);
|
||||
}
|
||||
|
||||
return static_cast<DObject*>(ptr)->GetClass();
|
||||
}
|
||||
|
||||
static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
||||
{
|
||||
#if COMPGOTO
|
||||
|
@ -140,12 +150,12 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
|||
|
||||
OP(CLSS):
|
||||
ASSERTA(a); ASSERTA(B);
|
||||
reg.a[a] = ((DObject*)reg.a[B])->GetClass(); // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer...
|
||||
reg.a[a] = GetClass(reg.a[B]);
|
||||
NEXTOP;
|
||||
|
||||
OP(META):
|
||||
ASSERTA(a); ASSERTA(B);
|
||||
reg.a[a] = ((DObject*)reg.a[B])->GetClass()->Meta; // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer...
|
||||
reg.a[a] = GetClass(reg.a[B])->Meta;
|
||||
NEXTOP;
|
||||
|
||||
OP(LB):
|
||||
|
|
Loading…
Reference in a new issue