ensure log context category is valid before reading it
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Mon, 7 Oct 2024 12:16:50 +0000 (14:16 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Mon, 7 Oct 2024 15:04:26 +0000 (17:04 +0200)
category of logs accessed via log context can be null
in such a case, strcmp will crash

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/logger.cpp

index 5e84be48ac0d7de09d6c4811adf036bf2735bfe1..86f482fffe490dc3f529a4b31f47b174feebcea1 100644 (file)
@@ -148,7 +148,7 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
             if (_doFileFlush)
                 _logstream->flush();
         }
-        if (_permanentDeleteLogStream && strcmp(ctx.category, lcPermanentLog().categoryName()) == 0) {
+        if (_permanentDeleteLogStream && ctx.category && strcmp(ctx.category, lcPermanentLog().categoryName()) == 0) {
             (*_permanentDeleteLogStream) << msg << "\n";
             _permanentDeleteLogStream->flush();
             if (_permanentDeleteLogFile.size() > 10LL * 1024LL) {