Skip to content

Commit 6904b38

Browse files
dwoodwor-intelsvenvh
authored andcommitted
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.
1 parent 2f69af2 commit 6904b38

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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)