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 298415fff3
This commit is contained in:
Peter Keresztes Schmidt 2021-05-22 10:52:57 +02:00
parent eb387b5453
commit e881e97c06
1 changed files with 2 additions and 2 deletions

View File

@ -530,7 +530,7 @@ void Logger::logPrint(bool hex, const char *filepath, int line, int level, const
if (zmDbConnected) {
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()));