From 58e3d96f8c28d039d757ffefb99bf16359dde2f6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Feb 2021 12:23:02 -0500 Subject: [PATCH] Instead of using basename and doing a strdup etc, just use strrchr because the filepath is going to one of the sources files in zm. --- src/zm_logger.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 1b314f7b7..744d8d005 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -439,8 +439,8 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con va_list argPtr; struct timeval timeVal; - char *filecopy = strdup(filepath); - const char * const file = basename(filecopy); + const char *base = strrchr(filepath, '/'); + const char *file = base ? base+1 : filepath; const char *classString = smCodes[level].c_str(); if ( level < PANIC || level > DEBUG9 ) @@ -567,7 +567,6 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con syslog(smSyslogPriorities[level], "%s [%s] [%s]", classString, mId.c_str(), syslogStart); } - free(filecopy); log_mutex.unlock(); if ( level <= FATAL ) { logTerm();