From f515d5415c3139483b47924cbd7bf876095e4598 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Mar 2015 09:24:21 +0100 Subject: [PATCH] Fix crash when Utility::BaseName fails Coverity Bug ID: 1167735 --- icinga-app/icinga.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 0cb447a7b..cb7309a52 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -284,7 +284,14 @@ int Main(void) } if (!command || vm.count("help") || vm.count("version")) { - String appName = Utility::BaseName(Application::GetArgV()[0]); + String appName; + + try { + Utility::BaseName(Application::GetArgV()[0]); + } catch (const std::bad_alloc&) { + Log(LogCritical, "icinga-app", "Allocation failed."); + return EXIT_FAILURE; + } if (appName.GetLength() > 3 && appName.SubStr(0, 3) == "lt-") appName = appName.SubStr(3, appName.GetLength() - 3);