From: Derek Schuff Date: Fri, 31 Mar 2017 22:14:14 +0000 (+0000) Subject: Add virtual destructor to WasmYAML::Section or avoid memory leak X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9120fd790435c128c5c7b510fbfd23c802eaff87;p=llvm Add virtual destructor to WasmYAML::Section or avoid memory leak Tested locally with -DLLVM_USE_SANITIZER=Address Differential Revision: https://reviews.llvm.org/D31551 Patch by Sam Clegg git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299270 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ObjectYAML/WasmYAML.h b/include/llvm/ObjectYAML/WasmYAML.h index ba993ea1873..0bcdb558aa0 100644 --- a/include/llvm/ObjectYAML/WasmYAML.h +++ b/include/llvm/ObjectYAML/WasmYAML.h @@ -108,6 +108,7 @@ struct Signature { struct Section { Section(SectionType SecType) : Type(SecType) {} + virtual ~Section(); SectionType Type; std::vector Relocations; diff --git a/lib/ObjectYAML/WasmYAML.cpp b/lib/ObjectYAML/WasmYAML.cpp index b82637a741b..3e1bed19d61 100644 --- a/lib/ObjectYAML/WasmYAML.cpp +++ b/lib/ObjectYAML/WasmYAML.cpp @@ -17,6 +17,15 @@ #include "llvm/Support/MipsABIFlags.h" namespace llvm { + +namespace WasmYAML { + +// Declared here rather than in the header to comply with: +// http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers +Section::~Section() {} + +} // end namespace WasmYAML + namespace yaml { void MappingTraits::mapping(