diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-23 18:18:37 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-23 18:18:37 +0000 |
commit | 538c9a88d9fca76f65cc1ae611992cea690c59e5 (patch) | |
tree | 5c4fd0786bdbc12c26b2dd9b752acc63a7e3647a /llvm/tools/gold/gold-plugin.cpp | |
parent | 122aeaafeacd8ab68b73f660da90acc675763bbb (diff) | |
download | bcm5719-llvm-538c9a88d9fca76f65cc1ae611992cea690c59e5.tar.gz bcm5719-llvm-538c9a88d9fca76f65cc1ae611992cea690c59e5.zip |
Fix a leak found by asan.
llvm-svn: 224776
Diffstat (limited to 'llvm/tools/gold/gold-plugin.cpp')
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index ee1cf979052..6b5864457a4 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -532,6 +532,13 @@ static Constant *mapConstantToLocalCopy(Constant *C, ValueToValueMapTy &VM, return MapValue(C, VM, RF_IgnoreMissingEntries, nullptr, Materializer); } +static void freeSymName(ld_plugin_symbol &Sym) { + free(Sym.name); + free(Sym.comdat_key); + Sym.name = nullptr; + Sym.comdat_key = nullptr; +} + static std::unique_ptr<Module> getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile, StringSet<> &Internalize, StringSet<> &Maybe) { @@ -581,8 +588,10 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile, *ApiFile << Sym.name << ' ' << getResolutionName(Resolution) << '\n'; GlobalValue *GV = Obj.getSymbolGV(ObjSym.getRawDataRefImpl()); - if (!GV) + if (!GV) { + freeSymName(Sym); continue; // Asm symbol. + } if (Resolution != LDPR_PREVAILING_DEF_IRONLY && GV->hasCommonLinkage()) { // Common linkage is special. There is no single symbol that wins the @@ -590,6 +599,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile, // The IR linker does that for us if we just pass it every common GV. // We still have to keep track of LDPR_PREVAILING_DEF_IRONLY so we // internalize once the IR linker has done its job. + freeSymName(Sym); continue; } @@ -642,10 +652,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile, } } - free(Sym.name); - free(Sym.comdat_key); - Sym.name = nullptr; - Sym.comdat_key = nullptr; + freeSymName(Sym); } ValueToValueMapTy VM; |