mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- fixed missing null pointer check in BuiltinNameToClass.
This commit is contained in:
parent
c73b71807b
commit
ca1981c52f
1 changed files with 8 additions and 14 deletions
|
@ -10739,27 +10739,21 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
|
|||
|
||||
int BuiltinNameToClass(VMValue *param, TArray<VMValue> &defaultparam, int numparam, VMReturn *ret, int numret)
|
||||
{
|
||||
assert(numparam == 2);
|
||||
assert(numret == 1);
|
||||
assert(param[0].Type == REGT_INT);
|
||||
assert(param[1].Type == REGT_POINTER);
|
||||
assert(ret->RegType == REGT_POINTER);
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_NAME(clsname);
|
||||
PARAM_CLASS(desttype, DObject);
|
||||
|
||||
FName clsname = ENamedName(param[0].i);
|
||||
PClass *cls = nullptr;
|
||||
if (clsname != NAME_None)
|
||||
{
|
||||
const PClass *cls = PClass::FindClass(clsname);
|
||||
const PClass *desttype = reinterpret_cast<PClass *>(param[1].a);
|
||||
|
||||
if (cls->VMType == nullptr || !cls->IsDescendantOf(desttype))
|
||||
cls = PClass::FindClass(clsname);
|
||||
if (cls != nullptr && (cls->VMType == nullptr || !cls->IsDescendantOf(desttype)))
|
||||
{
|
||||
// Let the caller check this. Making this an error with a message is only taking away options from the user.
|
||||
// does not match required parameters or is invalid.
|
||||
cls = nullptr;
|
||||
}
|
||||
ret->SetPointer(const_cast<PClass *>(cls));
|
||||
}
|
||||
else ret->SetPointer(nullptr);
|
||||
return 1;
|
||||
ACTION_RETURN_POINTER(cls);
|
||||
}
|
||||
|
||||
ExpEmit FxClassTypeCast::Emit(VMFunctionBuilder *build)
|
||||
|
|
Loading…
Reference in a new issue