Fix heap-use-after-free coff::createPDB
authorVitaly Buka <vitalybuka@google.com>
Mon, 14 Nov 2016 20:21:41 +0000 (20:21 +0000)
committerVitaly Buka <vitalybuka@google.com>
Mon, 14 Nov 2016 20:21:41 +0000 (20:21 +0000)
Summary:
getInputSections returns std::vector by value and ArrayRef
pointed to destroyed temporarily.

Reviewers: ruiu

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D26630

llvm-svn: 286880

lld/COFF/PDB.cpp

index 564648b..871cded 100644 (file)
@@ -82,9 +82,8 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
   IpiBuilder.setVersionHeader(pdb::PdbTpiV80);
 
   // Add Section Contributions.
-  ArrayRef<coff_section> InputSections = getInputSections(Symtab);
   std::vector<pdb::SectionContrib> Contribs =
-      pdb::DbiStreamBuilder::createSectionContribs(InputSections);
+      pdb::DbiStreamBuilder::createSectionContribs(getInputSections(Symtab));
   DbiBuilder.setSectionContribs(Contribs);
 
   // Add Section Map stream.