diff options
author | Nick Kledzik <kledzik@apple.com> | 2014-12-05 22:03:28 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2014-12-05 22:03:28 +0000 |
commit | e5da30cbd3644b6ef2c0f52a7eedc676d138f9e9 (patch) | |
tree | 5f9a11adf2618d9fa5aed337d32ae4a953ed3643 | |
parent | b7ec8ae2ab27524dd7c49e201c56b8007b940958 (diff) | |
download | bcm5719-llvm-e5da30cbd3644b6ef2c0f52a7eedc676d138f9e9.tar.gz bcm5719-llvm-e5da30cbd3644b6ef2c0f52a7eedc676d138f9e9.zip |
[mach-o] fix leak in atoms -> normalized
llvm-svn: 223530
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 19a7e45b4df..34781d56afd 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -95,6 +95,7 @@ class Util { public: Util(const MachOLinkingContext &ctxt) : _context(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {} + ~Util(); void assignAtomsToSections(const lld::File &atomFile); void organizeSections(); @@ -170,6 +171,22 @@ private: std::vector<const Atom *> _machHeaderAliasAtoms; }; +Util::~Util() { + // The SectionInfo structs are BumpPtr allocated, but atomsAndOffsets needs + // to be deleted. + for (SectionInfo *si : _sectionInfos) { + // clear() destroys vector elements, but does not deallocate. + // Instead use swap() to deallocate vector buffer. + std::vector<AtomInfo> empty; + si->atomsAndOffsets.swap(empty); + } + // The SegmentInfo structs are BumpPtr allocated, but sections needs + // to be deleted. + for (SegmentInfo *sgi : _segmentInfos) { + std::vector<SectionInfo*> empty2; + sgi->sections.swap(empty2); + } +} SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) { StringRef segmentName; |