From 8024f134587949c97c8bc6f7941a2aaac9af76fc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 May 2017 14:05:03 -0700 Subject: [PATCH] GUACAMOLE-306: Do not attempt to send VNC events with a non-existent VNC client object. --- src/protocols/vnc/clipboard.c | 5 +++-- src/protocols/vnc/input.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/protocols/vnc/clipboard.c b/src/protocols/vnc/clipboard.c index 8a802234..a49f5651 100644 --- a/src/protocols/vnc/clipboard.c +++ b/src/protocols/vnc/clipboard.c @@ -113,8 +113,9 @@ int guac_vnc_clipboard_end_handler(guac_user* user, guac_stream* stream) { guac_iconv(GUAC_READ_UTF8, &input, vnc_client->clipboard->length, writer, &output, sizeof(output_data)); - /* Send via VNC */ - SendClientCutText(rfb_client, output_data, output - output_data); + /* Send via VNC only if finished connecting */ + if (rfb_client != NULL) + SendClientCutText(rfb_client, output_data, output - output_data); return 0; } diff --git a/src/protocols/vnc/input.c b/src/protocols/vnc/input.c index d8fcda58..86f4ca76 100644 --- a/src/protocols/vnc/input.c +++ b/src/protocols/vnc/input.c @@ -30,11 +30,14 @@ int guac_vnc_user_mouse_handler(guac_user* user, int x, int y, int mask) { guac_client* client = user->client; guac_vnc_client* vnc_client = (guac_vnc_client*) client->data; + rfbClient* rfb_client = vnc_client->rfb_client; /* Store current mouse location */ guac_common_cursor_move(vnc_client->display->cursor, user, x, y); - SendPointerEvent(vnc_client->rfb_client, x, y, mask); + /* Send VNC event only if finished connecting */ + if (rfb_client != NULL) + SendPointerEvent(rfb_client, x, y, mask); return 0; } @@ -42,8 +45,11 @@ int guac_vnc_user_mouse_handler(guac_user* user, int x, int y, int mask) { int guac_vnc_user_key_handler(guac_user* user, int keysym, int pressed) { guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data; + rfbClient* rfb_client = vnc_client->rfb_client; - SendKeyEvent(vnc_client->rfb_client, keysym, pressed); + /* Send VNC event only if finished connecting */ + if (rfb_client != NULL) + SendKeyEvent(rfb_client, keysym, pressed); return 0; }