]> source.dussan.org Git - tigervnc.git/commitdiff
Make sure we always have a valid screen layout 761/head
authorPierre Ossman <ossman@cendio.se>
Thu, 1 Nov 2018 15:10:19 +0000 (16:10 +0100)
committerPierre Ossman <ossman@cendio.se>
Mon, 10 Dec 2018 19:19:43 +0000 (20:19 +0100)
Add more checks and fix some callers to make sure that the server
core always has a valid screen layout configured.

common/rfb/VNCServerST.cxx
unix/x0vncserver/XDesktop.cxx

index 8cc04f740812951bf55b9616502271db8bfb2013..a9ae62ebec9786f273eb6848391c98a995aed496 100644 (file)
@@ -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);
 }
 
index f8b579d7d62d9fbf025a4b0b3a969350e79f6d98..e77e765630156c4fbe74751d57e924bfeeb15571 100644 (file)
@@ -397,6 +397,11 @@ ScreenSet XDesktop::computeScreenLayout()
   }
 #endif
 
+  // Make sure that we have at least one screen
+  if (layout.num_screens() == 0)
+    layout.add_screen(rfb::Screen(0, 0, 0, geometry->width(),
+                                  geometry->height(), 0));
+
   return layout;
 }