From e881e97c067f5c883b52c9a5a2eacb74fc5c5e83 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sat, 22 May 2021 10:52:57 +0200 Subject: [PATCH] Logger: Fix DB log messages not being populated We need to `resize` the buffer string since `reserve` does not guarantee that the buffer is actually available. Follow-up on 298415fff3ceac53d3d972700b584c08672f91eb --- src/zm_logger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 872247701..266342ae4 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -528,9 +528,9 @@ void Logger::logPrint(bool hex, const char *filepath, int line, int level, const if (level <= mDatabaseLevel) { if (zmDbConnected) { - int syslogSize = syslogEnd-syslogStart; + int syslogSize = syslogEnd - syslogStart; std::string escapedString; - escapedString.reserve((syslogSize * 2) + 1); + escapedString.resize((syslogSize * 2) + 1); mysql_real_escape_string(&dbconn, &escapedString[0], syslogStart, syslogSize); escapedString.resize(std::strlen(escapedString.c_str()));