Skip to content

Commit b30a2d2

Browse files
authored
Check for nullptr from getDbgInst (#1919)
Ensure that ExprLB is non-NULL before using it. Signed-off-by: Lu, John <john.lu@intel.com>
1 parent 6a581e1 commit b30a2d2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,11 @@ SPIRVToLLVMDbgTran::transTypeArrayOpenCL(const SPIRVExtInst *DebugInst) {
262262
UpperBound, nullptr));
263263
continue;
264264
}
265-
if (auto *ExprUB = getDbgInst<SPIRVDebug::Expression>(Ops[I])) {
265+
if (const SPIRVExtInst * ExprUB, *ExprLB;
266+
(ExprUB = getDbgInst<SPIRVDebug::Expression>(Ops[I])) &&
267+
(ExprLB =
268+
getDbgInst<SPIRVDebug::Expression>(Ops[Ops.size() / 2 + I]))) {
266269
auto *UpperBound = transDebugInst<DIExpression>(ExprUB);
267-
auto *ExprLB =
268-
getDbgInst<SPIRVDebug::Expression>(Ops[Ops.size() / 2 + I]);
269270
auto *LowerBound = transDebugInst<DIExpression>(ExprLB);
270271
Subscripts.push_back(Builder.getOrCreateSubrange(nullptr, LowerBound,
271272
UpperBound, nullptr));

0 commit comments

Comments
 (0)