[icinga-checkins] icinga.org: icinga2/master: Fix memory leak for the 'use' keyword

git at icinga.org git at icinga.org
Fri Aug 19 09:33:46 CEST 2016


Module: icinga2
Branch: master
Commit: b5637a2d16cc8ffaf90bf8351380bc94a277e8b9
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=b5637a2d16cc8ffaf90bf8351380bc94a277e8b9

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Aug 19 09:07:57 2016 +0200

Fix memory leak for the 'use' keyword

fixes #12487

---

 lib/config/expression.hpp |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp
index 1c51cef..47f2627 100644
--- a/lib/config/expression.hpp
+++ b/lib/config/expression.hpp
@@ -802,6 +802,18 @@ public:
 		: DebuggableExpression(debugInfo), m_Args(args), m_Name(name), m_ClosedVars(closedVars), m_Expression(expression)
 	{ }
 
+	~FunctionExpression(void)
+	{
+		if (m_ClosedVars) {
+			typedef std::pair<String, Expression *> kv_pair;
+			BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) {
+				delete kv.second;
+			}
+		}
+
+		delete m_ClosedVars;
+	}
+
 protected:
 	virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
 
@@ -828,6 +840,15 @@ public:
 	~ApplyExpression(void)
 	{
 		delete m_Name;
+
+		if (m_ClosedVars) {
+			typedef std::pair<String, Expression *> kv_pair;
+			BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) {
+				delete kv.second;
+			}
+		}
+
+		delete m_ClosedVars;
 	}
 
 protected:
@@ -861,6 +882,15 @@ public:
 	~ObjectExpression(void)
 	{
 		delete m_Name;
+
+		if (m_ClosedVars) {
+			typedef std::pair<String, Expression *> kv_pair;
+			BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) {
+				delete kv.second;
+			}
+		}
+
+		delete m_ClosedVars;
 	}
 
 protected:



More information about the icinga-checkins mailing list