Remove memory corruption bug. string.c_str() was returning a temporary that was
authorNick Lewycky <nicholas@mxc.ca>
Tue, 28 Jul 2009 06:53:50 +0000 (06:53 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Tue, 28 Jul 2009 06:53:50 +0000 (06:53 +0000)
dead before we used it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77304 91177308-0d34-0410-b5e6-96231b3b80d8

tools/lto/LTOModule.cpp

index cbccfbb9b69ef25b9bdef2a9aa0ad84193ab9e51..4a2c5ad1dc3dcac9c6cc81c99ad462cd1a961ba1 100644 (file)
@@ -409,7 +409,7 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
     if (isa<GlobalAlias>(decl))
         return;
 
-    const char* name = mangler.getMangledName(decl).c_str();
+    std::string name = mangler.getMangledName(decl);
 
     // we already have the symbol
     if (_undefines.find(name) != _undefines.end())
@@ -417,7 +417,7 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
 
     NameAndAttributes info;
     // string is owned by _undefines
-    info.name = ::strdup(name);
+    info.name = ::strdup(name.c_str());
     if (decl->hasExternalWeakLinkage())
       info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF;
     else