From 489590cbd434facbb800e66a78a840f185ed7496 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 17 Nov 2013 14:04:33 +0000 Subject: [PATCH] Reliably initialise uxnet's socket fd fields to -1. This prevents embarrassing mess-ups involving getting back a Socket which has mostly been memset to 0 but contains an error message, sk_close()ing it to free the memory, and finding that standard input has been closed as a side effect. [originally from svn r10073] --- unix/uxnet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unix/uxnet.c b/unix/uxnet.c index 0bd0f9f5..449ea38a 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -799,6 +799,7 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i ret->incomingeof = FALSE; ret->listener = 1; ret->addr = NULL; + ret->s = -1; /* * Translate address_family from platform-independent constants @@ -1544,6 +1545,7 @@ Socket new_unix_listener(SockAddr listenaddr, Plug plug) ret->incomingeof = FALSE; ret->listener = 1; ret->addr = listenaddr; + ret->s = -1; assert(listenaddr->superfamily == UNIX);