summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-01-06 17:52:57 -0500
committerMichael Meeks <michael.meeks@collabora.com>2020-01-15 09:59:59 +0100
commit956c17afe9d5e33f53fd8d107e8384520e23d862 (patch)
tree6259123db3d0f55d2441362de2206bd1ca8ef7a0
parentAvoid taking address over the end of a vector if reading 0 bytes. (diff)
downloadonline-956c17afe9d5e33f53fd8d107e8384520e23d862.tar.gz
online-956c17afe9d5e33f53fd8d107e8384520e23d862.zip
wsd: handle rectangle=undefined gracefully
Change-Id: Ib9058956143aae8151c5e76fddff5dea313ff5e7 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86323 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit ad0256259bd8634cbd06b3ff5e881961f384023e) Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86360
-rw-r--r--kit/ChildSession.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index da16d807f8..ea7d26cd24 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1263,25 +1263,30 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st
int bufferWidth = 800, bufferHeight = 600;
double dpiScale = 1.0;
std::string paintRectangle;
- if (tokens.size() > 2 && getTokenString(tokens[2], "rectangle", paintRectangle))
+ if (tokens.size() > 2 && getTokenString(tokens[2], "rectangle", paintRectangle)
+ && paintRectangle != "undefined")
{
- const std::vector<std::string> rectParts = LOOLProtocol::tokenize(paintRectangle.c_str(), paintRectangle.length(), ',');
- startX = std::atoi(rectParts[0].c_str());
- startY = std::atoi(rectParts[1].c_str());
- bufferWidth = std::atoi(rectParts[2].c_str());
- bufferHeight = std::atoi(rectParts[3].c_str());
-
- std::string dpiScaleString;
- if (tokens.size() > 3 && getTokenString(tokens[3], "dpiscale", dpiScaleString))
+ const std::vector<std::string> rectParts
+ = LOOLProtocol::tokenize(paintRectangle.c_str(), paintRectangle.length(), ',');
+ if (rectParts.size() == 4)
{
- dpiScale = std::stod(dpiScaleString);
- if (dpiScale < 0.001)
- dpiScale = 1.0;
+ startX = std::atoi(rectParts[0].c_str());
+ startY = std::atoi(rectParts[1].c_str());
+ bufferWidth = std::atoi(rectParts[2].c_str());
+ bufferHeight = std::atoi(rectParts[3].c_str());
}
}
else
LOG_WRN("windowpaint command doesn't specify a rectangle= attribute.");
+ std::string dpiScaleString;
+ if (tokens.size() > 3 && getTokenString(tokens[3], "dpiscale", dpiScaleString))
+ {
+ dpiScale = std::stod(dpiScaleString);
+ if (dpiScale < 0.001)
+ dpiScale = 1.0;
+ }
+
size_t pixmapDataSize = 4 * bufferWidth * bufferHeight;
std::vector<unsigned char> pixmap(pixmapDataSize);
int width = bufferWidth, height = bufferHeight;