]> granicus.if.org Git - llvm/commitdiff
Add virtual destructor to WasmYAML::Section or avoid memory leak
authorDerek Schuff <dschuff@google.com>
Fri, 31 Mar 2017 22:14:14 +0000 (22:14 +0000)
committerDerek Schuff <dschuff@google.com>
Fri, 31 Mar 2017 22:14:14 +0000 (22:14 +0000)
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

include/llvm/ObjectYAML/WasmYAML.h
lib/ObjectYAML/WasmYAML.cpp

index ba993ea18734bbdd518686e1d9a052c6d2569d17..0bcdb558aa05b2a6837454664834800d7cc3d75b 100644 (file)
@@ -108,6 +108,7 @@ struct Signature {
 
 struct Section {
   Section(SectionType SecType) : Type(SecType) {}
+  virtual ~Section();
 
   SectionType Type;
   std::vector<Relocation> Relocations;
index b82637a741b393c7c0a88a204902d716f7fa2cf7..3e1bed19d61fe7004f21253f83d94bdbffd6ea7b 100644 (file)
 #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<WasmYAML::FileHeader>::mapping(