Script: don't crash on 0[n]

The typecheck relied on the fact that nullpointers were always C4V_Any,
which is not true anymore. Instead, directly check that the array that will
be used is not a nullpointer, which aligns the check with the usage instead
of C4Value implementation details.
Günther Brammer 2010-10-25 03:40:57 +02:00
parent 7fe7e074ad
commit 4438986167
1 changed files with 2 additions and 2 deletions

View File

@ -146,13 +146,13 @@ private:
C4V_Type CheckArrayAccess(C4Value *pStructure, C4Value *pIndex)
{
if (pStructure->ConvertTo(C4V_Array) && pStructure->GetType() != C4V_Any)
if (pStructure->ConvertTo(C4V_Array) && pStructure->_getArray())
{
if (!pIndex->ConvertTo(C4V_Int))
throw new C4AulExecError(pCurCtx->Obj, FormatString("array access: index of type %s, but expected int", pIndex->GetTypeName()).getData());
return C4V_Array;
}
else if (pStructure->ConvertTo(C4V_PropList) && pStructure->GetType() != C4V_Any)
else if (pStructure->ConvertTo(C4V_PropList) && pStructure->_getPropList())
{
if (!pIndex->ConvertTo(C4V_String) || !pIndex->_getStr())
throw new C4AulExecError(pCurCtx->Obj, FormatString("proplist access: index of type %s, but expected string", pIndex->GetTypeName()).getData());