Fixed crash with array initialization syntax going out of range (#698)

dev-time-step
krzys-h 2016-03-13 19:26:11 +01:00
parent cbdda57288
commit 4d99a62d37
2 changed files with 7 additions and 1 deletions

View File

@ -152,6 +152,12 @@ bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar)
pVar2 = pVar->GetItem(n, true);
if (pVar2 == nullptr)
{
pj->SetError(CBotErrOutArray, p->GetToken());
return false;
}
if (!p->Execute(pile1, pVar2)) return false; // evaluate expression
pile1->IncState();

View File

@ -415,7 +415,7 @@ public:
*
* \param index Index of the element to get
* \param grow true to grow the array automatically if the index is out of range
* \return CBotVar representing the array element
* \return CBotVar representing the array element, or nullptr on error (for example going out of range)
*/
virtual CBotVar* GetItem(int index, bool grow = false);