mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2025-04-05 21:23:18 +00:00
buffer_cache: avoid overflow in usage tracker
This commit is contained in:
parent
f9bfdb1555
commit
4eecad914a
@ -26,6 +26,9 @@ public:
|
|||||||
void Track(u64 offset, u64 size) noexcept {
|
void Track(u64 offset, u64 size) noexcept {
|
||||||
const size_t page = offset >> PAGE_SHIFT;
|
const size_t page = offset >> PAGE_SHIFT;
|
||||||
const size_t page_end = (offset + size) >> PAGE_SHIFT;
|
const size_t page_end = (offset + size) >> PAGE_SHIFT;
|
||||||
|
if (page_end < page || page_end >= pages.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TrackPage(page, offset, size);
|
TrackPage(page, offset, size);
|
||||||
if (page == page_end) {
|
if (page == page_end) {
|
||||||
return;
|
return;
|
||||||
@ -41,6 +44,9 @@ public:
|
|||||||
[[nodiscard]] bool IsUsed(u64 offset, u64 size) const noexcept {
|
[[nodiscard]] bool IsUsed(u64 offset, u64 size) const noexcept {
|
||||||
const size_t page = offset >> PAGE_SHIFT;
|
const size_t page = offset >> PAGE_SHIFT;
|
||||||
const size_t page_end = (offset + size) >> 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)) {
|
if (IsPageUsed(page, offset, size)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user