From f813e9f937b5b6198659c8c64b3090dc3902b930 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 1 Oct 2017 21:05:25 +0100 Subject: [PATCH] uxnet.c: don't close a socket's fd if it is -1. This is harmless in principle (you just get EBADF back from close(2) and ignore it), but it leads to warnings in valgrind. --- unix/uxnet.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unix/uxnet.c b/unix/uxnet.c index ddcd9228..f3498527 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -1023,9 +1023,11 @@ static void sk_tcp_close(Socket sock) if (s->child) sk_tcp_close((Socket)s->child); - uxsel_del(s->s); del234(sktree, s); - close(s->s); + if (s->s >= 0) { + uxsel_del(s->s); + close(s->s); + } if (s->addr) sk_addr_free(s->addr); sfree(s);