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

Jan Holesovsky kendy at collabora.com
Mon Nov 9 11:22:42 PST 2015


 loolwsd/LOOLSession.cpp |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 2dcfb61a6952377f0621d683018404291c6b8602
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Nov 9 20:08:19 2015 +0100

    loolwsd: Don't crash due to an uncaught std::out_of_range exception.
    
    Let's invalidate everything in such a case.

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 63380bc..883ebce 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -834,10 +834,24 @@ extern "C"
                 StringTokenizer tokens(std::string(pPayload), " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
                 if (tokens.count() == 4)
                 {
-                    int x(std::stoi(tokens[0]));
-                    int y(std::stoi(tokens[1]));
-                    int width(std::stoi(tokens[2]));
-                    int height(std::stoi(tokens[3]));
+                    int x, y, width, height;
+
+                    try {
+                        x = std::stoi(tokens[0]);
+                        y = std::stoi(tokens[1]);
+                        width = std::stoi(tokens[2]);
+                        height = std::stoi(tokens[3]);
+                    }
+                    catch (std::out_of_range&)
+                    {
+                        // something went wrong, invalidate everything
+                        Application::instance().logger().information(Util::logPrefix() + "Ignoring integer values out of range: " + pPayload);
+                        x = 0;
+                        y = 0;
+                        width = INT_MAX;
+                        height = INT_MAX;
+                    }
+
                     srv->sendTextFrame("invalidatetiles:"
                                        " part=" + std::to_string(curPart) +
                                        " x=" + std::to_string(x) +


More information about the Libreoffice-commits mailing list