1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 21:34:11 +02:00

Fixed attempted array allocation with negative dimension

This commit is contained in:
Brian Fiete 2021-09-28 13:25:15 -07:00
parent a5fff0fdbc
commit 6b9bb361f9

View file

@ -13772,6 +13772,11 @@ void BfExprEvaluator::CreateObject(BfObjectCreateExpression* objCreateExpr, BfAs
if ((constant != NULL) && (mModule->mBfIRBuilder->IsInt(constant->mTypeCode))) if ((constant != NULL) && (mModule->mBfIRBuilder->IsInt(constant->mTypeCode)))
{ {
int64 dimLength = constant->mInt64; int64 dimLength = constant->mInt64;
if (dimLength < 0)
{
mModule->Fail(StrFormat("Invalid array dimension '%lld'", dimLength), dimLengthRefs[dim]);
dimLength = -1;
}
dimLengths.push_back(dimLength); dimLengths.push_back(dimLength);
} }
else if ((constant != NULL) && (constant->mConstType == BfConstType_Undef)) else if ((constant != NULL) && (constant->mConstType == BfConstType_Undef))