From e1880f62ab08f7f960b4810ddd58a7345ebab50b Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 24 Sep 2021 15:11:22 +0100 Subject: [PATCH] Clamp value index by number of values * This can be out of bounds when purely considering the instruction index if there's an instruction near the end, beyond the point where there are (many) further values. --- renderdoc/driver/shaders/dxil/dxil_bytecode_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode_editor.cpp b/renderdoc/driver/shaders/dxil/dxil_bytecode_editor.cpp index 56f1a68ab..dd0e0e084 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode_editor.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode_editor.cpp @@ -754,7 +754,7 @@ const Constant *ProgramEditor::GetOrAddConstant(Function *f, const Constant &c) Instruction *ProgramEditor::AddInstruction(Function *f, size_t idx, const Instruction &inst) { - size_t valueIdx = f->constants.size() + idx; + size_t valueIdx = RDCMIN(f->values.size() - 1, f->constants.size() + idx); if(inst.type != m_VoidType) { // find the value index for the instruction we're inserting before. This won't match up exactly