From 829cdeb5e1ec3339e337082ae549bb3ee8c1aa79 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 12 Jul 2011 16:58:12 +0000 Subject: [PATCH] Mostly we will catch socket errors when processing incoming data, but sometimes we'll time it so that a write will be the initial offender. Make sure these cases are also properly caught and dealt with. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4583 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- vncviewer/Viewport.cxx | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 267c6f65..865143a0 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -327,7 +327,13 @@ int Viewport::handle(int event) assert(ret < (Fl::event_length() + 1)); vlog.debug("Sending clipboard data: '%s'", buffer); - cc->writer()->clientCutText(buffer, ret); + + try { + cc->writer()->clientCutText(buffer, ret); + } catch (rdr::Exception& e) { + vlog.error(e.str()); + exit_vncviewer(e.str()); + } delete [] buffer; @@ -455,7 +461,12 @@ void Viewport::handlePointerEvent(const rfb::Point& pos, int buttonMask) { if (!viewOnly) { if (pointerEventInterval == 0 || buttonMask != lastButtonMask) { - cc->writer()->pointerEvent(pos, buttonMask); + try { + cc->writer()->pointerEvent(pos, buttonMask); + } catch (rdr::Exception& e) { + vlog.error(e.str()); + exit_vncviewer(e.str()); + } } else { if (!Fl::has_timeout(handlePointerTimeout, this)) Fl::add_timeout((double)pointerEventInterval/1000.0, @@ -473,7 +484,12 @@ void Viewport::handlePointerTimeout(void *data) assert(self); - self->cc->writer()->pointerEvent(self->lastPointerPos, self->lastButtonMask); + try { + self->cc->writer()->pointerEvent(self->lastPointerPos, self->lastButtonMask); + } catch (rdr::Exception& e) { + vlog.error(e.str()); + exit_vncviewer(e.str()); + } } @@ -683,7 +699,12 @@ void Viewport::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, vlog.debug("Key released: 0x%04x => 0x%04x", origKeyCode, iter->second); - cc->writer()->keyEvent(iter->second, false); + try { + cc->writer()->keyEvent(iter->second, false); + } catch (rdr::Exception& e) { + vlog.error(e.str()); + exit_vncviewer(e.str()); + } downKeySym.erase(iter); @@ -698,7 +719,13 @@ void Viewport::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, origKeyCode, keyCode, keyText, keySym); downKeySym[origKeyCode] = keySym; - cc->writer()->keyEvent(keySym, down); + + try { + cc->writer()->keyEvent(keySym, down); + } catch (rdr::Exception& e) { + vlog.error(e.str()); + exit_vncviewer(e.str()); + } } -- 2.39.5