Skip to content

Commit 03d9929

Browse files
bashbaugjsji
authored andcommitted
fix possible nullptr dereference (#3000)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@c9a7f1328de9e6a
1 parent a341dc4 commit 03d9929

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ Value *SPIRVToLLVM::transConvertInst(SPIRVValue *BV, Function *F,
10981098
unsigned TotalBitWidth =
10991099
DstVecTy->getElementType()->getIntegerBitWidth() *
11001100
DstVecTy->getNumElements();
1101-
auto *IntTy = Type::getIntNTy(BB->getContext(), TotalBitWidth);
1101+
auto *IntTy = Type::getIntNTy(Src->getContext(), TotalBitWidth);
11021102
if (BB) {
11031103
Src = CastInst::CreatePointerCast(Src, IntTy, "", BB);
11041104
} else {
@@ -1112,7 +1112,7 @@ Value *SPIRVToLLVM::transConvertInst(SPIRVValue *BV, Function *F,
11121112
unsigned TotalBitWidth =
11131113
SrcVecTy->getElementType()->getIntegerBitWidth() *
11141114
SrcVecTy->getNumElements();
1115-
auto *IntTy = Type::getIntNTy(BB->getContext(), TotalBitWidth);
1115+
auto *IntTy = Type::getIntNTy(Src->getContext(), TotalBitWidth);
11161116
if (BB) {
11171117
Src = CastInst::Create(Instruction::BitCast, Src, IntTy, "", BB);
11181118
} else {

0 commit comments

Comments
 (0)