]> granicus.if.org Git - icinga2/commitdiff
Fix memory leak for the 'use' keyword
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 19 Aug 2016 07:07:57 +0000 (09:07 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 19 Aug 2016 07:17:40 +0000 (09:17 +0200)
fixes #12487

lib/config/expression.hpp

index 1c51cef7b59a164b8da225dfb8fe15fe2d8234e2..47f2627cfd0572a7373eaaa7a4f90aefcd8d037b 100644 (file)
@@ -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: