diff options
| author | Dan Engelbrecht <[email protected]> | 2024-08-12 15:35:14 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-12 15:35:14 +0200 |
| commit | 88a7f6029514b90ab7dad1e47951d03bd75fcb30 (patch) | |
| tree | f015e04bbadb6deedd6482fa7b7c3e578450db8d /src/zenstore/blockstore.cpp | |
| parent | project store chunk requests that are out of range will be treated as not fou... (diff) | |
| download | zen-88a7f6029514b90ab7dad1e47951d03bd75fcb30.tar.xz zen-88a7f6029514b90ab7dad1e47951d03bd75fcb30.zip | |
Skip chunk in block stores when iterating a block if the location is out of range (#109)
Diffstat (limited to 'src/zenstore/blockstore.cpp')
| -rw-r--r-- | src/zenstore/blockstore.cpp | 9 |
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]; |