Module: check_mk
Branch: master
Commit: c6ee5f88b7c0c4b5e24a0aff1cf172e05b6d3440
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c6ee5f88b7c0c4…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Nov 8 13:52:00 2016 +0100
Fixed potential segfault.
---
livestatus/src/CommandsHolderNagios.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/livestatus/src/CommandsHolderNagios.cc
b/livestatus/src/CommandsHolderNagios.cc
index 903d051..6b49c31 100644
--- a/livestatus/src/CommandsHolderNagios.cc
+++ b/livestatus/src/CommandsHolderNagios.cc
@@ -30,8 +30,10 @@ using std::vector;
CommandsHolder::Command CommandsHolderNagios::find(string name) const {
// Older Nagios headers are not const-correct... :-P
- command *cmd = find_command(const_cast<char *>(name.c_str()));
- return {cmd->name, cmd->command_line};
+ if (command *cmd = find_command(const_cast<char *>(name.c_str()))) {
+ return {cmd->name, cmd->command_line};
+ }
+ return {"", ""};
}
vector<CommandsHolder::Command> CommandsHolderNagios::commands() const {