]> granicus.if.org Git - icinga2/commitdiff
Fix memory leak when evaluating init.conf
authorGunnar Beutner <gunnar@beutner.name>
Wed, 4 Mar 2015 07:22:14 +0000 (08:22 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 4 Mar 2015 07:22:14 +0000 (08:22 +0100)
refs #8593

icinga-app/icinga.cpp

index cb7309a5267a351da9a61c78e7c606c0fee3153a..3a7ba1442faded7d1033cc57e8f8e2015b83ecde 100644 (file)
@@ -213,9 +213,20 @@ int Main(void)
        String initconfig = Application::GetSysconfDir() + "/icinga2/init.conf";
 
        if (Utility::PathExists(initconfig)) {
-               ScriptFrame frame;
-               Expression *expression = ConfigCompiler::CompileFile(initconfig);
-               expression->Evaluate(frame);
+               Expression *expression;
+               try {
+                       expression = ConfigCompiler::CompileFile(initconfig);
+
+                       ScriptFrame frame;
+                       expression->Evaluate(frame);
+               } catch (const std::exception& ex) {
+                       delete expression;
+
+                       Log(LogCritical, "config", DiagnosticInformation(ex));
+                       return EXIT_FAILURE;
+               }
+
+               delete expression;
        }
 
 #ifndef _WIN32