summaryrefslogtreecommitdiff
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-04-06 01:11:10 +0000
committerIvan Krasin <krasin@chromium.org>2016-04-06 01:11:10 +0000
commitbfc9131454a8a95196463612a49266ec1ae25bbd (patch)
tree983fe31d9c595cc660e28d30fb902ca5505bbbc4 /lld/ELF/InputFiles.cpp
parentbbadf2b7e574a636a5b7e01c705b785e113fd951 (diff)
Fix a memory leak found by check-lld asan tests.
Summary: This bug was introduced by http://reviews.llvm.org/rL265059, where InputSectionBase got Thunks field, which can do memory allocations. Since InputSectionBase destructors were never called (I count it as another bug), that caused a memory leak when 2 or more thunks are added to a section. The fix to is properly call InputSectionBase destructors from ~ObjectFile. Reviewers: atanasyan, ruiu, rafael Subscribers: rafael, krasin, pcc Differential Revision: http://reviews.llvm.org/D18809 llvm-svn: 265497
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 72fc3c93a83d..8256b3bfd9ac 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -204,7 +204,7 @@ void elf::ObjectFile<ELFT>::initializeSections(
// If -r is given, we do not interpret or apply relocation
// but just copy relocation sections to output.
if (Config->Relocatable) {
- Sections[I] = new (Alloc) InputSection<ELFT>(this, &Sec);
+ Sections[I] = new (IAlloc.Allocate()) InputSection<ELFT>(this, &Sec);
break;
}
@@ -278,7 +278,7 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
return new (EHAlloc.Allocate()) EHInputSection<ELFT>(this, &Sec);
if (shouldMerge<ELFT>(Sec))
return new (MAlloc.Allocate()) MergeInputSection<ELFT>(this, &Sec);
- return new (Alloc) InputSection<ELFT>(this, &Sec);
+ return new (IAlloc.Allocate()) InputSection<ELFT>(this, &Sec);
}
template <class ELFT> void elf::ObjectFile<ELFT>::initializeSymbols() {