From b51fd4d06cecd43299a8c923bc066d65776cc422 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 21 Apr 2021 13:11:10 +0200 Subject: [PATCH] [d3d11] Add range checking to IAGetVertexBuffers --- src/d3d11/d3d11_context.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 5d4b4e278..c22bdce42 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1708,14 +1708,25 @@ namespace dxvk { D3D10DeviceLock lock = LockContext(); for (uint32_t i = 0; i < NumBuffers; i++) { - if (ppVertexBuffers != nullptr) - ppVertexBuffers[i] = m_state.ia.vertexBuffers[StartSlot + i].buffer.ref(); + const bool inRange = StartSlot + i < m_state.ia.vertexBuffers.size(); + + if (ppVertexBuffers != nullptr) { + ppVertexBuffers[i] = inRange + ? m_state.ia.vertexBuffers[StartSlot + i].buffer.ref() + : nullptr; + } - if (pStrides != nullptr) - pStrides[i] = m_state.ia.vertexBuffers[StartSlot + i].stride; + if (pStrides != nullptr) { + pStrides[i] = inRange + ? m_state.ia.vertexBuffers[StartSlot + i].stride + : 0u; + } - if (pOffsets != nullptr) - pOffsets[i] = m_state.ia.vertexBuffers[StartSlot + i].offset; + if (pOffsets != nullptr) { + pOffsets[i] = inRange + ? m_state.ia.vertexBuffers[StartSlot + i].offset + : 0u; + } } }