From ef9ad29b7f94d567d15c4e0481b147f4454e3cb0 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 21 Apr 2021 13:14:36 +0200 Subject: [PATCH] [d3d11] Add range checking to GetConstantBuffers --- 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 5afc0a145..d0796ae9f 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3775,14 +3775,25 @@ namespace dxvk { UINT* pFirstConstant, UINT* pNumConstants) { for (uint32_t i = 0; i < NumBuffers; i++) { - if (ppConstantBuffers != nullptr) - ppConstantBuffers[i] = Bindings[StartSlot + i].buffer.ref(); + const bool inRange = StartSlot + i < Bindings.size(); + + if (ppConstantBuffers != nullptr) { + ppConstantBuffers[i] = inRange + ? Bindings[StartSlot + i].buffer.ref() + : nullptr; + } - if (pFirstConstant != nullptr) - pFirstConstant[i] = Bindings[StartSlot + i].constantOffset; + if (pFirstConstant != nullptr) { + pFirstConstant[i] = inRange + ? Bindings[StartSlot + i].constantOffset + : 0u; + } - if (pNumConstants != nullptr) - pNumConstants[i] = Bindings[StartSlot + i].constantCount; + if (pNumConstants != nullptr) { + pNumConstants[i] = inRange + ? Bindings[StartSlot + i].constantCount + : 0u; + } } }