aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-11-01 16:10:19 +0100
committerPierre Ossman <ossman@cendio.se>2018-12-10 20:19:43 +0100
commitc3826bb2fcb60efa495b54dd66296bc55ce28ecf (patch)
tree567e73ee6158b76636a2ca3995e867d7c72afddb /common/rfb
parent46c2c4627340c0c107ce31b95806ab77c157d3a6 (diff)
downloadtigervnc-c3826bb2fcb60efa495b54dd66296bc55ce28ecf.tar.gz
tigervnc-c3826bb2fcb60efa495b54dd66296bc55ce28ecf.zip
Make sure we always have a valid screen layout
Add more checks and fix some callers to make sure that the server core always has a valid screen layout configured.
Diffstat (limited to 'common/rfb')
-rw-r--r--common/rfb/VNCServerST.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 8cc04f74..a9ae62eb 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -305,8 +305,6 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
delete comparer;
comparer = 0;
- screenLayout = layout;
-
if (!pb) {
screenLayout = ScreenSet();
@@ -316,16 +314,17 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
return;
}
+ if (!layout.validate(pb->width(), pb->height()))
+ throw Exception("setPixelBuffer: invalid screen layout");
+
+ screenLayout = layout;
+
// Assume the framebuffer contents wasn't saved and reset everything
// that tracks its contents
comparer = new ComparingUpdateTracker(pb);
renderedCursorInvalid = true;
add_changed(pb->getRect());
- // Make sure that we have at least one screen
- if (screenLayout.num_screens() == 0)
- screenLayout.add_screen(Screen(0, 0, 0, pb->width(), pb->height(), 0));
-
std::list<VNCSConnectionST*>::iterator ci, ci_next;
for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
ci_next = ci; ci_next++;
@@ -359,6 +358,10 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_)
}
}
+ // Make sure that we have at least one screen
+ if (layout.num_screens() == 0)
+ layout.add_screen(Screen(0, 0, 0, pb->width(), pb->height(), 0));
+
setPixelBuffer(pb_, layout);
}