mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-18 11:30:59 +01:00
buffer_cache: avoid overflow in usage tracker (#13166)
This commit is contained in:
parent
9bc85dda5f
commit
1de37306a5
1 changed files with 6 additions and 0 deletions
|
@ -26,6 +26,9 @@ public:
|
|||
void Track(u64 offset, u64 size) noexcept {
|
||||
const size_t page = offset >> PAGE_SHIFT;
|
||||
const size_t page_end = (offset + size) >> PAGE_SHIFT;
|
||||
if (page_end < page || page_end >= pages.size()) {
|
||||
return;
|
||||
}
|
||||
TrackPage(page, offset, size);
|
||||
if (page == page_end) {
|
||||
return;
|
||||
|
@ -41,6 +44,9 @@ public:
|
|||
[[nodiscard]] bool IsUsed(u64 offset, u64 size) const noexcept {
|
||||
const size_t page = offset >> PAGE_SHIFT;
|
||||
const size_t page_end = (offset + size) >> PAGE_SHIFT;
|
||||
if (page_end < page || page_end >= pages.size()) {
|
||||
return false;
|
||||
}
|
||||
if (IsPageUsed(page, offset, size)) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue