From d5a1d64b4283fc34b22c84ebf4eb6a683471ff0d Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 14 Nov 2023 12:17:39 +0100 Subject: [PATCH] [d3d9] Return empty buffer slice for out-of-bounds offsets Fixes #3715. --- src/d3d9/d3d9_common_buffer.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d3d9/d3d9_common_buffer.h b/src/d3d9/d3d9_common_buffer.h index 782be42742f..745961980aa 100644 --- a/src/d3d9/d3d9_common_buffer.h +++ b/src/d3d9/d3d9_common_buffer.h @@ -125,7 +125,12 @@ namespace dxvk { template inline DxvkBufferSlice GetBufferSlice(VkDeviceSize offset, VkDeviceSize length) const { - return DxvkBufferSlice(GetBuffer(), offset, length); + if (likely(length && offset < m_desc.Size)) { + return DxvkBufferSlice(GetBuffer(), offset, + std::min(m_desc.Size - offset, length)); + } + + return DxvkBufferSlice(); } inline DxvkBufferSliceHandle AllocMapSlice() {