From 04ce389dc8134713bbb4b4f8cf637606b7eb814e Mon Sep 17 00:00:00 2001 From: MaranBr Date: Tue, 28 Oct 2025 10:28:36 -0400 Subject: [PATCH] Add one more check --- src/video_core/buffer_cache/buffer_cache.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 6b4e7e4ff0..68786fa887 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -1575,20 +1575,21 @@ void BufferCache

::MappedUploadMemory(Buffer& buffer, auto upload_staging = runtime.UploadStagingBuffer(total_size_bytes); const std::span staging_pointer = upload_staging.mapped_span; if (staging_pointer.size() < total_size_bytes) { - LOG_ERROR(HW_GPU, "Staging buffer too small for total size bytes"); + LOG_ERROR(HW_GPU, "Staging buffer too small for total_size_bytes ({} bytes required, {} bytes available)", total_size_bytes, staging_pointer.size()); return; } for (BufferCopy& copy : copies) { if (copy.src_offset + copy.size > staging_pointer.size()) { - LOG_ERROR(HW_GPU, "Copy exceeds staging buffer bounds (src_offset: {}, size: {})", copy.src_offset, copy.size); + LOG_ERROR(HW_GPU, "Copy exceeds staging buffer bounds. src_offset: {}, size: {}", copy.src_offset, copy.size); return; } u8* const src_pointer = staging_pointer.data() + copy.src_offset; - if (copy.dst_offset + copy.size > buffer.SizeBytes()) { - LOG_ERROR(HW_GPU, "Copy exceeds buffer bounds (dst_offset: {}, size: {})", copy.dst_offset, copy.size); + const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset; + u8* dst_pointer = device_memory.GetSpan(device_addr, copy.size); + if (dst_pointer == nullptr) { + LOG_ERROR(HW_GPU, "Attempted copy out of bounds. Destination offset: {}, size: {}, device buffer address: {}", copy.dst_offset, copy.size, device_addr); return; } - const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset; device_memory.ReadBlockUnsafe(device_addr, src_pointer, copy.size); copy.src_offset += upload_staging.offset; }