diff options
author | liamwhite <[email protected]> | 2024-02-27 09:39:11 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-02-27 15:39:11 +0100 |
commit | 1de37306a521a3ee22f1f6703fa9c2f8169dcacb (patch) | |
tree | b6c1b734b448c1de56c9fbb6113f8e8baa0cc741 | |
parent | 9bc85dda5fce187e90cbca4644ebea17cc058d7f (diff) | |
download | yuzu-mainline-1de37306a521a3ee22f1f6703fa9c2f8169dcacb.tar.gz yuzu-mainline-1de37306a521a3ee22f1f6703fa9c2f8169dcacb.zip |
buffer_cache: avoid overflow in usage tracker (#13166)
-rw-r--r-- | src/video_core/buffer_cache/usage_tracker.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/usage_tracker.h b/src/video_core/buffer_cache/usage_tracker.h index 5f8688d31..ae511ccb6 100644 --- a/src/video_core/buffer_cache/usage_tracker.h +++ b/src/video_core/buffer_cache/usage_tracker.h @@ -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; } |