Fix memory leak when evaluating init.conf

refs #8593
This commit is contained in:
Gunnar Beutner 2015-03-04 08:22:14 +01:00
parent 9bbe9a4875
commit b4143c2724
1 changed files with 14 additions and 3 deletions

View 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