[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-0' - loolwsd/ChildProcessSession.cpp loolwsd/LOKitHelper.hpp

Henry Castro hcastro at collabora.com
Sun May 29 16:07:26 UTC 2016


 loolwsd/ChildProcessSession.cpp |   11 +++++++----
 loolwsd/LOKitHelper.hpp         |    9 +++++++--
 2 files changed, 14 insertions(+), 6 deletions(-)

New commits:
commit 4f08267fe7af7bcac663b7aad18cbbc7dc750439
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed May 25 00:32:00 2016 -0400

    loolwsd: deallocates memory previously allocated by malloc
    
    (cherry picked from commit bf1a4705e4d343b4a6031e85d8d3644decf3ddac)
    
    Change-Id: I70e2542b6c992694d7bc8df178eea34d363f303c
    Reviewed-on: https://gerrit.libreoffice.org/25614
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 21c2aad..bf3b11b 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -397,13 +397,13 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length)
 
     if (tokens[0] == "dummymsg")
     {
-        // Just to update the activity of view-only mode
+        // Just to update the activity of a view-only client.
         return true;
     }
     else if (tokens[0] == "canceltiles")
     {
-        // this command makes sense only on the command queue level, nothing
-        // to do here
+        // This command makes sense only on the command queue level.
+        // Shouldn't get this here.
         return true;
     }
     else if (tokens[0] == "commandvalues")
@@ -566,6 +566,7 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length)
             assert(false);
         }
     }
+
     return true;
 }
 
@@ -697,7 +698,9 @@ bool ChildProcessSession::getCommandValues(const char* /*buffer*/, int /*length*
     if (_multiView)
         _loKitDocument->pClass->setView(_loKitDocument, _viewId);
 
-    sendTextFrame("commandvalues: " + std::string(_loKitDocument->pClass->getCommandValues(_loKitDocument, command.c_str())));
+    char* ptrValues = _loKitDocument->pClass->getCommandValues(_loKitDocument, command.c_str());
+    sendTextFrame("commandvalues: " + std::string(ptrValues));
+    std::free(ptrValues);
     return true;
 }
 
diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index cfc3fec..46d40b1 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -107,6 +107,7 @@ namespace LOKitHelper
     inline
     std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
     {
+        char* ptrValue;
         assert(loKitDocument && "null loKitDocument");
         const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
 
@@ -128,11 +129,15 @@ namespace LOKitHelper
                 oss << "\n";
                 if (type == LOK_DOCTYPE_PRESENTATION)
                 {
-                    oss << loKitDocument->pClass->getPartHash(loKitDocument, i);
+                    ptrValue = loKitDocument->pClass->getPartHash(loKitDocument, i);
+                    oss << ptrValue;
+                    std::free(ptrValue);
                 }
                 else
                 {
-                    oss << loKitDocument->pClass->getPartName(loKitDocument, i);
+                    ptrValue = loKitDocument->pClass->getPartName(loKitDocument, i);
+                    oss << ptrValue;
+                    std::free(ptrValue);
                 }
             }
         }


More information about the Libreoffice-commits mailing list