add assert to make sure other_id array index is in bounds

develop
Ben Lubar 2020-04-27 18:56:48 -05:00
parent fc10ed3df6
commit 7cf9624de9
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
1 changed files with 2 additions and 0 deletions

@ -574,6 +574,8 @@ namespace DFHack
{
std::vector<I *> & operator[](O other_id)
{
CHECK_INVALID_ARGUMENT(size_t(other_id) < sizeof(*this) / sizeof(std::vector<I *>));
auto vectors = reinterpret_cast<std::vector<I *> *>(this);
return vectors[other_id];
}