From 9ed410668c19ddd6b2c12709d6a5383e7f7a6e07 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Thu, 5 Nov 2009 16:25:30 +0100 Subject: Fix checks for socket values, 0 is a legal value. To make this work, we also have to initialize sockets to a default value of -1. Also close a client listen socket if it's open. Signed-off-by: Christian Beier Signed-off-by: Johannes Schindelin --- libvncclient/vncviewer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libvncclient/vncviewer.c') diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c index b5fb420..0361827 100644 --- a/libvncclient/vncviewer.c +++ b/libvncclient/vncviewer.c @@ -190,7 +190,8 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel, #ifdef LIBVNCSERVER_WITH_CLIENT_TLS client->tlsSession = NULL; #endif - + client->sock = -1; + client->listenSock = -1; return client; } @@ -334,8 +335,10 @@ void rfbClientCleanup(rfbClient* client) { #endif FreeTLS(client); - if (client->sock > 0) + if (client->sock >= 0) close(client->sock); + if (client->listenSock >= 0) + close(client->listenSock); free(client->desktopName); free(client->serverHost); free(client); -- cgit v1.2.1