Summary: dynamic's integer type is signed, so make sure array indices
are not negative.
(See https://our.intern.facebook.com/intern/tasks/?t=
7445055)
Reviewed By: @Gownta
Differential Revision:
D2145689
if (!idx.isInt()) {
throw TypeError("int64", idx.type());
}
- if (idx >= parray->size()) {
+ if (idx < 0 || idx >= parray->size()) {
throw std::out_of_range("out of range in dynamic array");
}
return (*parray)[idx.asInt()];
EXPECT_EQ(array.at(1), 2);
EXPECT_EQ(array.at(2), 3);
+ EXPECT_ANY_THROW(array.at(-1));
EXPECT_ANY_THROW(array.at(3));
array.push_back("foo");