From e78c20c0f87ec30c7cbeb76aa8e16b6afea1c655 Mon Sep 17 00:00:00 2001 From: Matthias Vallentin Date: Fri, 3 May 2013 14:26:02 -0700 Subject: [PATCH] Fix memory-leak in OpaqueVal. Addresses #986. --- src/Val.cc | 3 ++- src/Val.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Val.cc b/src/Val.cc index dd86e71a9e..2aafc30ab2 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -3125,12 +3125,13 @@ void VectorVal::ValDescribe(ODesc* d) const d->Add("]"); } -OpaqueVal::OpaqueVal(OpaqueType* t) : Val(t) +OpaqueVal::OpaqueVal(OpaqueType* t) : Val(t), type(t) { } OpaqueVal::~OpaqueVal() { + Unref(type); } IMPLEMENT_SERIAL(OpaqueVal, SER_OPAQUE_VAL); diff --git a/src/Val.h b/src/Val.h index 4b2705c5b4..8544fbadfd 100644 --- a/src/Val.h +++ b/src/Val.h @@ -1024,6 +1024,9 @@ protected: OpaqueVal() { } DECLARE_SERIAL(OpaqueVal); + +private: + OpaqueType* type; }; // Checks the given value for consistency with the given type. If an