]> granicus.if.org Git - icinga2/commitdiff
Fix crash when Utility::BaseName fails
authorGunnar Beutner <gunnar@beutner.name>
Tue, 3 Mar 2015 08:24:21 +0000 (09:24 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 3 Mar 2015 08:24:21 +0000 (09:24 +0100)
Coverity Bug ID: 1167735

icinga-app/icinga.cpp

index 0cb447a7baef5125a5ea78fb71d75b13a9b1198a..cb7309a5267a351da9a61c78e7c606c0fee3153a 100644 (file)
@@ -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);