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 committed by Isaac Connor
parent 6a9ed9c457
commit e659543d0a
1 changed files with 2 additions and 2 deletions

View File

@ -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()));