loolwsd/LOOLKit.cpp |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit fad6715f7d69b3e551deca566d72cfd1b7302d50
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Tue Aug 30 19:23:51 2016 -0400

    loolwsd: guard against processing commands before fully loading
    
    Change-Id: Iac915074728f616d81b05558b886998855326a2e
    Reviewed-on: https://gerrit.libreoffice.org/28525
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index a2ff02e..d3c98b7 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -705,6 +705,12 @@ public:
         }
 
         std::unique_lock<std::mutex> lock(_loKitDocument->getLock());
+        if (_loKitDocument->getViews() <= 0)
+        {
+            Log::error("Tile rendering requested without views.");
+            return;
+        }
+
         Timestamp timestamp;
         _loKitDocument->paintPartTile(pixmap.data(), tileCombined.getPart(),
                                       pixmapWidth, pixmapHeight,
@@ -998,14 +1004,15 @@ private:
 
         auto session = it->second->getSession();
         int viewId = 0;
+        std::unique_lock<std::mutex> lockLokDoc;
 
         if (!_loKitDocument)
         {
             // This is the first time we are loading the document
             Log::info("Loading new document from URI: [" + uri + "] for 
session [" + sessionId + "].");
 
-
             auto lock(_loKit->getLock());
+
             if (LIBREOFFICEKIT_HAS(_loKit->get(), registerCallback))
             {
                 _loKit->get()->pClass->registerCallback(_loKit->get(), 
GlobalCallback, this);
@@ -1023,6 +1030,8 @@ private:
             Log::debug("Calling lokit::documentLoad.");
             _loKitDocument = _loKit->documentLoad(uri.c_str());
             Log::debug("Returned lokit::documentLoad.");
+            auto l(_loKitDocument->getLock());
+            lockLokDoc.swap(l);
 
             if (!_loKitDocument || !_loKitDocument->get())
             {
@@ -1058,6 +1067,9 @@ private:
         }
         else
         {
+            auto l(_loKitDocument->getLock());
+            lockLokDoc.swap(l);
+
             // Check if this document requires password
             if (_isDocPasswordProtected)
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to