aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/blockstore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore/blockstore.cpp')
-rw-r--r--src/zenstore/blockstore.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 4b650e2d5..09f55af0e 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -1068,7 +1068,8 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
return ChunkLocations[IndexA].Offset < ChunkLocations[IndexB].Offset;
});
- auto GetNextRange = [LargeSizeLimit, IterateSmallChunkWindowSize, &ChunkLocations](std::span<const size_t> ChunkIndexes,
+ auto GetNextRange = [LargeSizeLimit, IterateSmallChunkWindowSize, &ChunkLocations](uint64_t BlockFileSize,
+ std::span<const size_t> ChunkIndexes,
size_t StartIndexOffset) -> size_t {
size_t ChunkCount = 0;
size_t StartIndex = ChunkIndexes[StartIndexOffset];
@@ -1080,6 +1081,10 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
size_t NextIndex = ChunkIndexes[StartIndexOffset + ChunkCount];
const BlockStoreLocation& Location = ChunkLocations[NextIndex];
ZEN_ASSERT(Location.BlockIndex == StartLocation.BlockIndex);
+ if ((Location.Offset + Location.Size) > BlockFileSize)
+ {
+ break;
+ }
if (Location.Size > LargeSizeLimit)
{
break;
@@ -1130,7 +1135,7 @@ BlockStore::IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
const BlockStoreLocation& FirstLocation = ChunkLocations[ChunkIndex];
const size_t BlockSize = BlockFile->FileSize();
- const size_t RangeCount = GetNextRange(ChunkIndexes, LocationIndexOffset);
+ const size_t RangeCount = GetNextRange(BlockSize, ChunkIndexes, LocationIndexOffset);
if (RangeCount > 0)
{
size_t LastChunkIndex = ChunkIndexes[LocationIndexOffset + RangeCount - 1];