aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorliamwhite <[email protected]>2024-02-27 09:39:11 -0500
committerGitHub <[email protected]>2024-02-27 15:39:11 +0100
commit1de37306a521a3ee22f1f6703fa9c2f8169dcacb (patch)
treeb6c1b734b448c1de56c9fbb6113f8e8baa0cc741
parent9bc85dda5fce187e90cbca4644ebea17cc058d7f (diff)
downloadyuzu-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.h6
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;
}