aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/vnc.c b/vnc.c
index 793687e..7db0c3c 100644
--- a/vnc.c
+++ b/vnc.c
@@ -159,11 +159,19 @@ static void vnc_window_conf(struct vnc_window *vnc)
static void vnc_release(struct vnc_window *vnc)
{
+ int sock = -1;
+
if (NULL == vnc)
return;
- if (vnc->connected) {
- if (vnc->client)
- rfbClientCleanup(vnc->client);
+ if (vnc->connected && vnc->client) {
+ /*
+ * library bugs?
+ * - calling rfbClientCleanup() unconnected segfaults
+ * - rfbClientCleanup() doesn't close the socket
+ */
+ sock = vnc->client->sock;
+ rfbClientCleanup(vnc->client);
+ vnc->client = NULL;
}
if (vnc->filter_installed)
gdk_window_remove_filter(vnc->draw->window, event_filter, vnc);
@@ -174,6 +182,8 @@ static void vnc_release(struct vnc_window *vnc)
x11_destroy_ximage(vnc->dpy, vnc->ximage, vnc->shm);
if (vnc->gc)
XFreeGC(vnc->dpy, vnc->gc);
+ if (-1 != sock)
+ close(sock);
free(vnc);
}