[llvm-commits] [llvm] r139846 - /llvm/trunk/lib/DebugInfo/DWARFContext.cpp

Benjamin Kramer benny.kra at googlemail.com
Thu Sep 15 14:08:54 PDT 2011


Author: d0k
Date: Thu Sep 15 16:08:54 2011
New Revision: 139846

URL: http://llvm.org/viewvc/llvm-project?rev=139846&view=rev
Log:
DWARF: Don't crash when looking up an invalid address.

Modified:
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=139846&r1=139845&r2=139846&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep 15 16:08:54 2011
@@ -147,13 +147,19 @@
   uint32_t cuOffset = getDebugAranges()->offsetAtIndex(arangeIndex);
   // Retrieve the compile unit.
   DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset);
+  if (!cu)
+    return DILineInfo("<invalid>", 0, 0);
   // Get the line table for this compile unit.
   const DWARFDebugLine::LineTable *lineTable = getLineTableForCompileUnit(cu);
+  if (!lineTable)
+    return DILineInfo("<invalid>", 0, 0);
   // Get the index of the row we're looking for in the line table.
   uint64_t hiPC =
     cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_high_pc,
                                                          -1ULL);
   uint32_t rowIndex = lineTable->lookupAddress(address, hiPC);
+  if (rowIndex == -1U)
+    return DILineInfo("<invalid>", 0, 0);
 
   // From here, contruct the DILineInfo.
   const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex];





More information about the llvm-commits mailing list