[llvm] r299270 - Add virtual destructor to WasmYAML::Section or avoid memory leak
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 15:14:15 PDT 2017
Author: dschuff
Date: Fri Mar 31 17:14:14 2017
New Revision: 299270
URL: http://llvm.org/viewvc/llvm-project?rev=299270&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h
llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
Modified: llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h?rev=299270&r1=299269&r2=299270&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h (original)
+++ llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h Fri Mar 31 17:14:14 2017
@@ -108,6 +108,7 @@ struct Signature {
struct Section {
Section(SectionType SecType) : Type(SecType) {}
+ virtual ~Section();
SectionType Type;
std::vector<Relocation> Relocations;
Modified: llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/WasmYAML.cpp?rev=299270&r1=299269&r2=299270&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/WasmYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/WasmYAML.cpp Fri Mar 31 17:14:14 2017
@@ -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<WasmYAML::FileHeader>::mapping(
More information about the llvm-commits
mailing list