OSDN Git Service

[llvm-pdbutil] Don't crash when a section contrib's isect is invalid.
authorZachary Turner <zturner@google.com>
Mon, 7 Aug 2017 20:24:01 +0000 (20:24 +0000)
committerZachary Turner <zturner@google.com>
Mon, 7 Aug 2017 20:24:01 +0000 (20:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310298 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-pdbutil/DumpOutputStyle.cpp

index 60e0b75..99dd358 100644 (file)
@@ -1180,8 +1180,12 @@ Error DumpOutputStyle::dumpSectionContribs() {
     }
     void visit(const SectionContrib &SC) override {
       assert(SC.ISect > 0);
-      StringRef SectionName = Names[SC.ISect - 1];
-      std::string NameInsert = formatv("[{0}]", SectionName).str();
+      std::string NameInsert;
+      if (SC.ISect < Names.size()) {
+        StringRef SectionName = Names[SC.ISect - 1];
+        NameInsert = formatv("[{0}]", SectionName).str();
+      } else
+        NameInsert = "[???]";
       P.formatLine("SC{5}  | mod = {2}, {0}, size = {1}, data crc = {3}, reloc "
                    "crc = {4}",
                    formatSegmentOffset(SC.ISect, SC.Off), fmtle(SC.Size),