]> granicus.if.org Git - icinga2/commitdiff
Fix a crash in the "repl" command
authorGunnar Beutner <gunnar.beutner@netways.de>
Sun, 23 Nov 2014 18:13:42 +0000 (19:13 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Sun, 23 Nov 2014 18:13:42 +0000 (19:13 +0100)
refs #7805

lib/cli/replcommand.cpp

index 29e3c707444a1b2a20983efc33f38f7d2d32f0c0..e22679c991b54efedbd091a51a6befc4d9a0372e 100644 (file)
@@ -73,11 +73,16 @@ int ReplCommand::Run(const po::variables_map& vm, const std::vector<std::string>
 
                        expr = ConfigCompiler::CompileText("<console>", line);
 
+                       bool has_errors = false;
+
                        BOOST_FOREACH(const ConfigCompilerMessage& message, ConfigCompilerContext::GetInstance()->GetMessages()) {
+                               if (message.Error)
+                                       has_errors = true;
+
                                std::cout << (message.Error ? "Error" : "Warning") << ": " << message.Text << "\n";
                        }
 
-                       if (expr) {
+                       if (expr && !has_errors) {
                                Value result = expr->Evaluate(frame);
                                std::cout << ConsoleColorTag(Console_ForegroundCyan);
                                if (!result.IsObject() || result.IsObjectType<Array>() || result.IsObjectType<Dictionary>())