[llvm-bugs] [Bug 32430] New: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp: PVS-Studio: CWE-476 (NULL Pointer Dereference)

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 27 06:38:48 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32430

            Bug ID: 32430
           Summary: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:
                    PVS-Studio: CWE-476 (NULL Pointer Dereference)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: razmyslov at viva64.com
                CC: llvm-bugs at lists.llvm.org

We have found a weakness using PVS-Studio tool. PVS-Studio is a static code
analyzer for C, C++ and C#: https://www.viva64.com/en/pvs-studio/

Analyzer warning: V595 The 'DIExpr' pointer was utilized before it was verified
against nullptr. Check lines: 949, 950. codeviewdebug.cpp 949

void CodeViewDebug::collectVariableInfo(const DISubprogram *SP) {
  ....
  const DIExpression *DIExpr = DVInst->getDebugExpression();
  bool IsSubfield = false;
  unsigned StructOffset = 0;

  // Handle fragments.
  auto Fragment = DIExpr->getFragmentInfo();   // <=
  if (DIExpr && Fragment) {                    // <=
    IsSubfield = true;
    StructOffset = Fragment->OffsetInBits / 8;
  } else if (DIExpr && DIExpr->getNumElements() > 0) {
    continue; // Ignore unrecognized exprs.
  }
  ....
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170327/539e7887/attachment.html>


More information about the llvm-bugs mailing list