[Libreoffice-commits] online.git: loolwsd/Log.cpp

Miklos Vajna vmiklos at collabora.co.uk
Mon Aug 15 16:49:38 UTC 2016


 loolwsd/Log.cpp |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit c47c4fe5a487dd249c4e0a67b25a7a419c732a84
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Aug 15 15:22:14 2016 +0200

    Log: clean up unnecessary channelConsole
    
    splitterChannel can be a raw pointer, at the end it'll be assigned to
    channel, which does not call duplicate() on it. As a side effect this
    fixes the use-after-free warnings reported by clang-tidy.
    
    Change-Id: I8f5d7c9f6c8f280c9f1222c2ab6d7b0fddf64a30
    Reviewed-on: https://gerrit.libreoffice.org/28145
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/Log.cpp b/loolwsd/Log.cpp
index 7365c99..3471b4b 100644
--- a/loolwsd/Log.cpp
+++ b/loolwsd/Log.cpp
@@ -123,15 +123,14 @@ namespace Log
         strncpy(LogPrefix, oss.str().c_str(), sizeof(LogPrefix));
 
         // Configure the logger.
-        AutoPtr<Channel> channelConsole = (isatty(fileno(stderr)) || withColor
-                            ? static_cast<Poco::Channel*>(new Poco::ColorConsoleChannel())
-                            : static_cast<Poco::Channel*>(new Poco::ConsoleChannel()));
+        AutoPtr<Channel> channel = (isatty(fileno(stderr)) || withColor
+                                    ? static_cast<Poco::Channel*>(new Poco::ColorConsoleChannel())
+                                    : static_cast<Poco::Channel*>(new Poco::ConsoleChannel()));
 
-        AutoPtr<Channel> channel = channelConsole;
         if (logToFile)
         {
-            AutoPtr<SplitterChannel> splitterChannel(new SplitterChannel());
-            splitterChannel->addChannel(channelConsole);
+            auto splitterChannel(new SplitterChannel());
+            splitterChannel->addChannel(channel);
 
             AutoPtr<FileChannel> rotatedFileChannel(new FileChannel("loolwsd.log"));
             for (const auto& pair : config)


More information about the Libreoffice-commits mailing list