[PATCH 31/79] [Backport to 15] Check for nullptr from getDbgInst (#1919)
authorLU-JOHN <111294400+LU-JOHN@users.noreply.github.com>
Fri, 31 Mar 2023 16:53:15 +0000 (11:53 -0500)
committerAndreas Beckmann <anbe@debian.org>
Thu, 14 Mar 2024 19:01:08 +0000 (20:01 +0100)
Ensure that ExprLB is non-NULL before using it.

Signed-off-by: Lu, John <john.lu@intel.com>
Gbp-Pq: Name 0031-Backport-to-15-Check-for-nullptr-from-getDbgInst-191.patch

lib/SPIRV/SPIRVToLLVMDbgTran.cpp

index 28b2170ebf65df0472670e159e64d32191a3a638..54339fbcdf279ae1d687e0bdf1a77f623bfdd912 100644 (file)
@@ -271,10 +271,11 @@ SPIRVToLLVMDbgTran::transTypeArrayOpenCL(const SPIRVExtInst *DebugInst) {
                                                        UpperBound, nullptr));
       continue;
     }
-    if (auto *ExprUB = getDbgInst<SPIRVDebug::Expression>(Ops[I])) {
+    const SPIRVExtInst *ExprUB, *ExprLB;
+    if ((ExprUB = getDbgInst<SPIRVDebug::Expression>(Ops[I])) &&
+        (ExprLB =
+             getDbgInst<SPIRVDebug::Expression>(Ops[Ops.size() / 2 + I]))) {
       auto *UpperBound = transDebugInst<DIExpression>(ExprUB);
-      auto *ExprLB =
-          getDbgInst<SPIRVDebug::Expression>(Ops[Ops.size() / 2 + I]);
       auto *LowerBound = transDebugInst<DIExpression>(ExprLB);
       Subscripts.push_back(Builder.getOrCreateSubrange(nullptr, LowerBound,
                                                        UpperBound, nullptr));