Fix heap-use-after-free coff::createPDB
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
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 564648b..871cded 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -82,9 +82,8 @@
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.