]> source.dussan.org Git - tigervnc.git/commitdiff
Fixed a bug with dereferencing a zero pointer in x0vncserver.
authorConstantin Kaplinsky <const@tightvnc.com>
Tue, 18 Apr 2006 08:57:17 +0000 (08:57 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Tue, 18 Apr 2006 08:57:17 +0000 (08:57 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/merge-with-vnc-4.1.1@540 3789f03b-4d11-0410-bbf8-ca57d06f2519

x0vncserver/x0vncserver.cxx

index 212ae076475378b8d999ea8ef1dffb5e511065cb..dac2e7c7b323e3a3e74e9e5bd7fa2c23039ceeaa 100644 (file)
@@ -132,7 +132,7 @@ class XDesktop : public SDesktop, public ColourMap
 public:
   XDesktop(Display* dpy_)
         : dpy(dpy_), pb(0), server(0), image(0), pollmgr(0),
-      oldButtonMask(0), haveXtest(false), maxButtons(0)
+          oldButtonMask(0), haveXtest(false), maxButtons(0), running(false)
   {
 #ifdef HAVE_XTEST
     int xtestEventBase;
@@ -193,16 +193,28 @@ public:
                                   (rdr::U8*)image->xim->data, this);
     server = vs;
     server->setPixelBuffer(pb);
+
+    running = true;
   }
 
   virtual void stop() {
+    running = false;
+
+    // FIXME: Delete images as well?!
     delete pb;
     delete pollmgr;
-    // FIXME: Delete images as well?!
+
+    pb = 0;
+    pollmgr = 0;
+  }
+
+  inline bool isRunning() {
+    return running;
   }
 
   inline void poll() {
-    pollmgr->poll();
+    if (pollmgr)
+      pollmgr->poll();
   }
 
   virtual void pointerEvent(const Point& pos, int buttonMask) {
@@ -265,6 +277,7 @@ protected:
   int oldButtonMask;
   bool haveXtest;
   int maxButtons;
+  bool running;
 };
 
 
@@ -509,6 +522,10 @@ int main(int argc, char** argv)
           server.processSocketEvent(*i);
       }
 
+      // Don't poll if the desktop object in not ready.
+      if (!desktop.isRunning())
+        continue;
+
       server.checkTimeouts();
 
       if (sched.goodTimeToPoll()) {