diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-08-10 00:33:24 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-08-10 00:33:24 +0200 |
| commit | 2b062ae29bbc86008899c05e807fd9096ed9720d (patch) | |
| tree | 2300bfb437e712f20fc098d2885226f385054fdf /src/logger.cc | |
| parent | 3b2878883540874a45a68afe39aa8ce6920650f7 (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
Diffstat (limited to 'src/logger.cc')
| -rw-r--r-- | src/logger.cc | 8 |
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 { |
