Skip to content

Commit 360e781

Browse files
committed
Check for out of bounds. Fixes rakudo crash on "Buf.new.subbuf(0, 1)\;
1 parent daae9b5 commit 360e781

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/vm/parrot/6model/reprs/VMArray.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ static void at_pos_native(PARROT_INTERP, STable *st, void *data, INTVAL index, N
401401
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
402402
"VMArray: Can't get unboxed string value");
403403

404+
if (index >= body->elems) {
405+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
406+
"VMArray: index out of bounds");
407+
}
408+
404409
if(repr_data->elem_kind == STORAGE_SPEC_BP_INT) {
405410
value->value.intval = get_pos_int(interp, body, repr_data, body->start + index);
406411
}

0 commit comments

Comments
 (0)