aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--monitor.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/monitor.cc b/monitor.cc
index 4a95293..524b9ae 100644
--- a/monitor.cc
+++ b/monitor.cc
@@ -288,7 +288,10 @@ parseResults(const char *resultStr)
} else {
hname = he->h_name;
/* Remove domain name from end of hostname. */
- hname.erase(hname.find_first_of('.'));
+ size_t dot = hname.find_first_of('.');
+ if (dot != std::string::npos) {
+ hname.erase(dot);
+ }
}
std::ostringstream hostname;
hostname << hname;