diff options
Diffstat (limited to 'vnc.c')
-rw-r--r-- | vnc.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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); } |