Added an out-of-bounds check

This commit is contained in:
2022-09-09 19:52:36 +01:00
parent f2443fbde0
commit d3c085c300
3 changed files with 32 additions and 2 deletions

View File

@@ -495,7 +495,19 @@ int _index(Interpreter* interpreter, LiteralArray* arguments) {
if (IS_NULL(second)) {
//set the "first" within the array, then skip out
setLiteralArray(AS_ARRAY(compound), first, assign);
if (!setLiteralArray(AS_ARRAY(compound), first, assign)) {
interpreter->errorOutput("Index assignment out of bounds\n");
freeLiteral(op);
freeLiteral(assign);
freeLiteral(third);
freeLiteral(second);
freeLiteral(first);
freeLiteral(compound);
freeLiteral(value);
return -1;
}
pushLiteralArray(&interpreter->stack, compound);