summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-08-10 00:33:24 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-08-10 00:33:24 +0200
commit2b062ae29bbc86008899c05e807fd9096ed9720d (patch)
tree2300bfb437e712f20fc098d2885226f385054fdf
parent3b2878883540874a45a68afe39aa8ce6920650f7 (diff)
tp in daemon mode with syslog used the wrong name
Need to keep the string given to openlog() alive while syslog is used or it will use random other memory in that location
-rw-r--r--src/logger.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/logger.cc b/src/logger.cc
index e04b588..da097a1 100644
--- a/src/logger.cc
+++ b/src/logger.cc
@@ -40,8 +40,9 @@ public:
class LoggerSyslog : public Logger {
public:
- LoggerSyslog(std::string const& name) {
- openlog(name.c_str(), LOG_PID, LOG_DAEMON);
+ LoggerSyslog(std::string const& name)
+ : name_(name) {
+ openlog(name_.c_str(), LOG_PID, LOG_DAEMON);
}
~LoggerSyslog() override {
@@ -75,6 +76,9 @@ private:
assert(false);
return LOG_INFO;
}
+
+ // Copy of name to keep pointer alive while syslog has access to it
+ std::string const name_;
};
class LoggerFile : public Logger {