net/Socket.hpp     |    4 ++++
 net/Ssl.cpp        |    1 +
 wsd/FileServer.hpp |    3 +++
 wsd/LOOLWSD.cpp    |    2 ++
 4 files changed, 10 insertions(+)

New commits:
commit 4f8ebca0cb3612ddbdcfbee6ea5a462b04689738
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Jul 2 22:10:23 2017 -0400

    wsd: free leaking memory
    
    With help from Valgrind to find and verify
    these leaks.
    
    Change-Id: I3afeed89dc4bcd714a222f81822144477a346fb0
    Reviewed-on: https://gerrit.libreoffice.org/39464
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/net/Socket.hpp b/net/Socket.hpp
index d1d3018d..f3cf623c 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -615,6 +615,10 @@ private:
 
             // Invoke the virtual implementation.
             pollingThread();
+
+            // Release sockets.
+            _pollSockets.clear();
+            _newSockets.clear();
         }
         catch (const std::exception& exc)
         {
diff --git a/net/Ssl.cpp b/net/Ssl.cpp
index e350257c..7c04cbd9 100644
--- a/net/Ssl.cpp
+++ b/net/Ssl.cpp
@@ -123,6 +123,7 @@ SslContext::SslContext(const std::string& certFilePath,
 
 SslContext::~SslContext()
 {
+    SSL_CTX_free(_ctx);
     EVP_cleanup();
     ERR_free_strings();
     CRYPTO_set_locking_callback(0);
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index 01d5918c..c3ff59b7 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -31,6 +31,9 @@ public:
     /// Read all files that we can serve into memory and compress them.
     static void initialize();
 
+    /// Clean cached files.
+    static void uninitialize() { FileHash.clear(); }
+
     static void readDirToHash(const std::string &basePath, const std::string 
&path);
 
     static const std::string *getCompressedFile(const std::string &path);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index eecc6d27..a1272c20 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2672,6 +2672,8 @@ int LOOLWSD::innerMain()
 
 void LOOLWSD::cleanup()
 {
+    FileServerRequestHandler::uninitialize();
+
     // Finally, we no longer need SSL.
     if (LOOLWSD::isSSLEnabled())
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to