[lld] r240046 - COFF: Fix unsafe memory access.

Rui Ueyama ruiu at google.com
Thu Jun 18 13:29:41 PDT 2015


Author: ruiu
Date: Thu Jun 18 15:29:41 2015
New Revision: 240046

URL: http://llvm.org/viewvc/llvm-project?rev=240046&view=rev
Log:
COFF: Fix unsafe memory access.

Modified:
    lld/trunk/COFF/InputFiles.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=240046&r1=240045&r2=240046&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Thu Jun 18 15:29:41 2015
@@ -256,12 +256,13 @@ std::error_code BitcodeFile::parse() {
     return make_error_code(LLDError::BrokenFile);
   }
 
+  llvm::BumpPtrStringSaver Saver(Alloc);
   for (unsigned I = 0, E = M->getSymbolCount(); I != E; ++I) {
     lto_symbol_attributes Attrs = M->getSymbolAttributes(I);
     if ((Attrs & LTO_SYMBOL_SCOPE_MASK) == LTO_SYMBOL_SCOPE_INTERNAL)
       continue;
 
-    StringRef SymName = M->getSymbolName(I);
+    StringRef SymName = Saver.save(M->getSymbolName(I));
     int SymbolDef = Attrs & LTO_SYMBOL_DEFINITION_MASK;
     if (SymbolDef == LTO_SYMBOL_DEFINITION_UNDEFINED) {
       SymbolBodies.push_back(new (Alloc) Undefined(SymName));





More information about the llvm-commits mailing list