From b5637a2d16cc8ffaf90bf8351380bc94a277e8b9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 19 Aug 2016 09:07:57 +0200 Subject: [PATCH] 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 1c51cef7b..47f2627cf 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 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 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 kv_pair; + BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) { + delete kv.second; + } + } + + delete m_ClosedVars; } protected: