Avoid dereferencing iterators over empty indexed data values

It seems the values can be empty even if size of blocks
is non-zero (e.g. blocks.size()==1)
This commit is contained in:
Mateusz Łoskot 2020-11-23 21:21:35 +01:00
parent a3f1c2afb0
commit 58fbda0483
No known key found for this signature in database
GPG Key ID: 928D7C2ABB2AC1F2

View File

@ -331,6 +331,9 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe
// Return value at the given index
ResultType at(std::uint32_t index) const
{
if (values.empty())
return ResultType();
// Get block external ad internal indices
const BlocksNumberType block_idx = index / (BLOCK_SIZE + 1);
const std::uint32_t internal_idx = index % (BLOCK_SIZE + 1);