coverity 966576 - close socket in error path
authorTim Hudson <tjh@cryptsoft.com>
Mon, 5 May 2014 00:53:39 +0000 (10:53 +1000)
committerMatt Caswell <matt@openssl.org>
Thu, 8 May 2014 22:19:19 +0000 (23:19 +0100)
apps/s_socket.c

index d49837a40557af6757a2bfdb32f27ca61872d89e..94eb40f3ffc8777eaf87b036b4b723da95a94322 100644 (file)
@@ -450,6 +450,7 @@ redoit:
                if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
                        {
                        perror("OPENSSL_malloc");
+                       closesocket(ret);
                        return(0);
                        }
                BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
@@ -458,11 +459,13 @@ redoit:
                if (h2 == NULL)
                        {
                        BIO_printf(bio_err,"gethostbyname failure\n");
+                       closesocket(ret);
                        return(0);
                        }
                if (h2->h_addrtype != AF_INET)
                        {
                        BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
+                       closesocket(ret);
                        return(0);
                        }
                }