]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
protext all access to _logstream with the existing mutex
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 13 Apr 2023 16:41:44 +0000 (18:41 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Fri, 21 Apr 2023 08:32:43 +0000 (10:32 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/logger.cpp

index 42830d32f312582e0823e4a3964adeda10f0da2d..d38be4c6bf69358bbeac76045ca6441a76876588 100644 (file)
@@ -118,7 +118,6 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
     cout << msg << endl;
 #endif
     {
-        QMutexLocker lock(&_mutex);
         if (_logFile.size() >= MaxLogSizeBytes) {
             close();
             enterNextLogFile();
@@ -127,6 +126,8 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
         _crashLogIndex = (_crashLogIndex + 1) % CrashLogSize;
         _crashLog[_crashLogIndex] = msg;
 
+        QMutexLocker lock(&_mutex);
+
         if (_logstream) {
             (*_logstream) << msg << Qt::endl;
             if (_doFileFlush)
@@ -145,6 +146,7 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
 
 void Logger::close()
 {
+    QMutexLocker lock(&_mutex);
     dumpCrashLog();
     if (_logstream)
     {