mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +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.
|
#error vmexec.h must not be #included outside vmexec.cpp. Use vm.h instead.
|
||||||
#endif
|
#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)
|
static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
||||||
{
|
{
|
||||||
#if COMPGOTO
|
#if COMPGOTO
|
||||||
|
@ -140,12 +150,12 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
||||||
|
|
||||||
OP(CLSS):
|
OP(CLSS):
|
||||||
ASSERTA(a); ASSERTA(B);
|
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;
|
NEXTOP;
|
||||||
|
|
||||||
OP(META):
|
OP(META):
|
||||||
ASSERTA(a); ASSERTA(B);
|
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;
|
NEXTOP;
|
||||||
|
|
||||||
OP(LB):
|
OP(LB):
|
||||||
|
|
Loading…
Reference in a new issue