mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
- fixed the type checks for object arrays.
Null pointers must be allowed and non-object pointers which are not null must be explicitly checked for because the code could crash on them when performing a static_cast on an incorrect type.
This commit is contained in:
parent
a8d4d45e89
commit
3aef8418d9
1 changed files with 10 additions and 5 deletions
|
@ -8245,15 +8245,20 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
return nullptr;
|
||||
}
|
||||
if (isDynArrayObj && ((MethodName == NAME_Push && idx == 0) || (MethodName == NAME_Insert && idx == 1)))
|
||||
{
|
||||
// Null pointers are always valid.
|
||||
if (!a->isConstant() || static_cast<FxConstant*>(a)->GetValue().GetPointer() != nullptr)
|
||||
{
|
||||
// The DynArray_Obj declaration in dynarrays.txt doesn't support generics yet. Check the type here as if it did.
|
||||
if (!static_cast<PObjectPointer*>(elementType)->PointedClass()->IsAncestorOf(static_cast<PObjectPointer*>(a->ValueType)->PointedClass()))
|
||||
if (!a->ValueType->isObjectPointer() ||
|
||||
!static_cast<PObjectPointer*>(elementType)->PointedClass()->IsAncestorOf(static_cast<PObjectPointer*>(a->ValueType)->PointedClass()))
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Type mismatch in function argument");
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a->IsDynamicArray())
|
||||
{
|
||||
// Copy and Move must turn their parameter into a pointer to the backing struct type.
|
||||
|
|
Loading…
Reference in a new issue