We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5109b75 commit 06c6e4aCopy full SHA for 06c6e4a
cpp/MMapFile.h
@@ -292,7 +292,12 @@ class MMapFile {
292
293
// compute page-aligned offset and length
294
size_t pageSize = sysconf(_SC_PAGE_SIZE);
295
- size_t alignedOffset = offset - (offset % pageSize);
+ size_t alignedOffset = offset;
296
+ if (alignedOffset >= size_) [[unlikely]] {
297
+ alignedOffset = size_; // Adjust alignedOffset to not exceed the size of the file
298
+ }
299
+ alignedOffset -= (alignedOffset % pageSize); // Align to page size
300
+
301
length += (offset - alignedOffset);
302
if (alignedOffset + length > size_) [[unlikely]] {
303
length = size_ - alignedOffset; // Adjust length to not exceed the size of the file
0 commit comments