From: Timmons C. Player <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master
memory: fix off by 1 error in page_range_allocator
The page_range_allocator free() method neglected to subtract
1 from the index when checking the end of the page range in
the _bitmap. Fix the calculation.
Note: with this change, the end index calculated by free() now
matches the end index calculated in set_bits().
Signed-off-by: Timmons C. Player <[email protected]>
---
diff --git a/core/mempool.cc b/core/mempool.cc
--- a/core/mempool.cc
+++ b/core/mempool.cc
@@ -767,7 +767,7 @@ void page_range_allocator::free(page_range* pr)
pr2->size += pr->size;
pr = pr2;
}
- if (_bitmap[get_bitmap_idx(*pr) + pr->size / page_size]) {
+ if (_bitmap[get_bitmap_idx(*pr) + pr->size / page_size - 1]) {
auto pr2 = static_cast<page_range*>(static_cast<void*>(pr) +
pr->size);
remove(*pr2);
pr->size += pr2->size;
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.