From 58fbda0483c3982966339a5e9aa8cb3ee2969fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Mon, 23 Nov 2020 21:21:35 +0100 Subject: [PATCH] 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) --- include/util/indexed_data.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/util/indexed_data.hpp b/include/util/indexed_data.hpp index 8df3c350a..4c0bb297a 100644 --- a/include/util/indexed_data.hpp +++ b/include/util/indexed_data.hpp @@ -331,6 +331,9 @@ template 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);