]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Reliably initialise uxnet's socket fd fields to -1.
authorSimon Tatham <anakin@pobox.com>
Sun, 17 Nov 2013 14:04:33 +0000 (14:04 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 17 Nov 2013 14:04:33 +0000 (14:04 +0000)
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.

git-svn-id: http://svn.tartarus.org/sgt/putty@10073 cda61777-01e9-0310-a592-d414129be87e

unix/uxnet.c

index 0bd0f9f5efb06055ea6ab897450ce3b95aebf30b..449ea38a7e40abb9db6cdb8a8f27031407fc4d53 100644 (file)
@@ -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);