[GPU]: Prevent out-of-bounds access in VisitImageView

This commit is contained in:
liberodark 2025-12-07 13:25:38 +01:00
parent ea4672b4a8
commit fbb0862d79
2 changed files with 3 additions and 5 deletions

View file

@ -1,6 +1,3 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later

View file

@ -498,8 +498,9 @@ template <class P>
ImageViewId TextureCache<P>::VisitImageView(DescriptorTable<TICEntry>& table, ImageViewId TextureCache<P>::VisitImageView(DescriptorTable<TICEntry>& table,
std::span<ImageViewId> cached_image_view_ids, std::span<ImageViewId> cached_image_view_ids,
u32 index) { u32 index) {
if (index > table.Limit()) { const u32 limit = table.Limit();
LOG_DEBUG(HW_GPU, "Invalid image view index={}", index); const size_t cache_size = cached_image_view_ids.size();
if (index > limit || index >= cache_size) {
return NULL_IMAGE_VIEW_ID; return NULL_IMAGE_VIEW_ID;
} }
const auto [descriptor, is_new] = table.Read(index); const auto [descriptor, is_new] = table.Read(index);