[Libreoffice-commits] online.git: 2 commits - gtk/mobile.cpp net/WebSocketHandler.hpp wsd/LOOLWSD.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 25 18:34:55 UTC 2018


 gtk/mobile.cpp           |   14 ++++++++++----
 net/WebSocketHandler.hpp |    2 +-
 wsd/LOOLWSD.cpp          |    6 +++---
 3 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 8bc97c0f9e6b0fa7483b44ed6faa6bfbc2f17999
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 25 21:33:57 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 25 21:33:57 2018 +0300

    Adapt after 4724aa0cf78f3aedf7f7f4222d251ef8395d5523

diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 3b60fe9b8..f6457787e 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -205,7 +205,7 @@ public:
         } else
             _wsPayload.insert(_wsPayload.end(), data, data + payloadLen);
 #else
-        unsigned char * const p = reinterpret_cast<unsigned char*>(&socket->_inBuffer[0]);
+        unsigned char * const p = reinterpret_cast<unsigned char*>(&socket->getInBuffer()[0]);
         _wsPayload.insert(_wsPayload.end(), p, p + len);
         const size_t headerLen = 0;
         const size_t payloadLen = len;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3f3748247..2af6a1591 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1845,7 +1845,7 @@ private:
 #else
             Poco::Process::PID pid = 1;
             std::string jailId = "jail";
-            socket->_inBuffer.clear();
+            socket->getInBuffer().clear();
 #endif
             LOG_TRC("Calling make_shared<ChildProcess>, for NewChildren?");
 
@@ -2108,8 +2108,8 @@ private:
         socket->eraseFirstInputBytes(requestSize);
 #else
         Poco::Net::HTTPRequest request;
-        handleClientWsUpgrade(request, std::string(socket->_inBuffer.data(), socket->_inBuffer.size()), disposition);
-        socket->_inBuffer.clear();
+        handleClientWsUpgrade(request, std::string(socket->getInBuffer().data(), socket->getInBuffer().size()), disposition);
+        socket->getInBuffer().clear();
 #endif
     }
 
commit 16a805e290e5a276f44728cf428efe7f31de0622
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 25 21:27:48 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 25 21:28:13 2018 +0300

    Fix some memory management foo

diff --git a/gtk/mobile.cpp b/gtk/mobile.cpp
index 760d62c10..a45ebf990 100644
--- a/gtk/mobile.cpp
+++ b/gtk/mobile.cpp
@@ -27,9 +27,13 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <cstdlib>
+#include <cstring>
 #include <iostream>
 #include <thread>
 
+#include <string.h>
+
 #include <gtk/gtk.h>
 #include <webkit2/webkit2.h>
 
@@ -56,7 +60,7 @@ static void send2JS_ready_callback(GObject      *source_object,
                                    GAsyncResult *res,
                                    gpointer     user_data)
 {
-    g_free(user_data);
+    free(user_data);
 }
 
 static void send2JS(const std::vector<char>& buffer)
@@ -102,7 +106,7 @@ static void send2JS(const std::vector<char>& buffer)
         data.push_back(0);
 
         js = "window.TheFakeWebSocket.onmessage({'data': '";
-        js = js + std::string(buffer.data());
+        js = js + std::string(buffer.data(), buffer.size());
         js = js + "'});";
     }
 
@@ -228,13 +232,15 @@ static void handle_lool_message(WebKitUserContentManager *manager,
         else
         {
             // As above
-            std::thread([&]
+            char *string_copy = strdup(string_value);
+            std::thread([=]
                         {
                             struct pollfd pollfd;
                             pollfd.fd = fakeClientFd;
                             pollfd.events = POLLOUT;
                             fakeSocketPoll(&pollfd, 1, -1);
-                            fakeSocketWrite(fakeClientFd, string_value, strlen(string_value));
+                            fakeSocketWrite(fakeClientFd, string_copy, strlen(string_copy));
+                            free(string_copy);
                         }).detach();
         }
         g_free(string_value);


More information about the Libreoffice-commits mailing list