]> git.kaiwu.me - klib.git/commitdiff
avoid a segfault when connection fails
authorHeng Li <lh3@live.co.uk>
Sun, 30 Jan 2011 02:55:39 +0000 (21:55 -0500)
committerHeng Li <lh3@live.co.uk>
Sun, 30 Jan 2011 02:55:39 +0000 (21:55 -0500)
knetfile.c

index d7672eab1feca009a52bee6e0b63df3842187d26..af091465862c238aefeb3d0562b03f75320b6c1d 100644 (file)
@@ -89,7 +89,7 @@ static int socket_connect(const char *host, const char *port)
 
        int on = 1, fd;
        struct linger lng = { 0, 0 };
-       struct addrinfo hints, *res;
+       struct addrinfo hints, *res = 0;
        memset(&hints, 0, sizeof(struct addrinfo));
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;