Fix crash when Utility::BaseName fails

Coverity Bug ID: 1167735
This commit is contained in:
Gunnar Beutner 2015-03-03 09:24:21 +01:00
parent ba6b92a929
commit f515d5415c
1 changed files with 8 additions and 1 deletions

View File

@ -284,7 +284,14 @@ int Main(void)
} }
if (!command || vm.count("help") || vm.count("version")) { 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-") if (appName.GetLength() > 3 && appName.SubStr(0, 3) == "lt-")
appName = appName.SubStr(3, appName.GetLength() - 3); appName = appName.SubStr(3, appName.GetLength() - 3);