Skip to content

Commit 23d7ef6

Browse files
committed
libvncclient: sockets: don't leak socket when SetNonBlocking fails
Closes #678
1 parent 7be47a2 commit 23d7ef6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/libvncclient/sockets.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ ConnectClientToUnixSockWithTimeout(const char *sockFile, unsigned int timeout)
495495
return RFB_INVALID_SOCKET;
496496
}
497497

498-
if (!SetNonBlocking(sock))
499-
return RFB_INVALID_SOCKET;
498+
if (!SetNonBlocking(sock)) {
499+
rfbCloseSocket(sock);
500+
return RFB_INVALID_SOCKET;
501+
}
500502

501503
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0 &&
502504
!(errno == EINPROGRESS && sock_wait_for_connected(sock, timeout))) {

0 commit comments

Comments
 (0)