Skip to content

Commit d176dad

Browse files
Fix out of bounds access in SPIRVToOCLBase::mutateArgsForImageOperands
When called from visitCallSPIRVImageReadBuiltIn, Args only has three elements and ImOpArgIndex is 2. This has been causing this function to "update" an argument past the end of the vector, which caused a crash when running transcoding/image_signedness.ll on Windows because the debug build in Windows has bounds checking on std::vector. With this change, it should update the correct (and not past the end) argument instead and satisfy the Windows bounds checks. Original commit: KhronosGroup/SPIRV-LLVM-Translator@6904b38
1 parent 5b61278 commit d176dad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVToOCL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ void SPIRVToOCLBase::mutateArgsForImageOperands(std::vector<Value *> &Args,
785785
if (ImOpValue & ImageOperandsMask::ImageOperandsZeroExtendMask)
786786
IsSigned = false;
787787
ImOpValue &= ~SignZeroExtMasks;
788-
Args[3] = getInt32(M, ImOpValue);
789-
ImOp = cast<ConstantInt>(Args[3]);
788+
Args[ImOpArgIndex] = getInt32(M, ImOpValue);
789+
ImOp = cast<ConstantInt>(Args[ImOpArgIndex]);
790790
}
791791
// Drop "Image Operands" argument.
792792
Args.erase(Args.begin() + ImOpArgIndex);

0 commit comments

Comments
 (0)