Fixed sockfd/socketBio resource leak.
authorArmin Novak <armin.novak@thincast.com>
Thu, 25 Oct 2018 11:19:22 +0000 (13:19 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 25 Oct 2018 11:41:47 +0000 (13:41 +0200)
libfreerdp/core/gateway/rdg.c
libfreerdp/core/gateway/rpc.c

index b1bab48..ca678ce 100644 (file)
@@ -328,7 +328,7 @@ static wStream* rdg_build_http_request(rdpRdg* rdg, const char* method,
        HttpRequest* request = NULL;
        const char* uri;
 
-       if (!rdg || !method )
+       if (!rdg || !method)
                return NULL;
 
        uri = http_context_get_uri(rdg->http);
@@ -693,9 +693,7 @@ static BOOL rdg_tls_connect(rdpRdg* rdg, rdpTls* tls, const char* peerAddress, i
                                     peerPort, timeout);
 
        if (sockfd < 0)
-       {
                return FALSE;
-       }
 
        socketBio = BIO_new(BIO_s_simple_socket());
 
@@ -710,8 +708,7 @@ static BOOL rdg_tls_connect(rdpRdg* rdg, rdpTls* tls, const char* peerAddress, i
 
        if (!bufferedBio)
        {
-               closesocket(sockfd);
-               BIO_free(socketBio);
+               BIO_free_all(socketBio);
                return FALSE;
        }
 
@@ -722,7 +719,10 @@ static BOOL rdg_tls_connect(rdpRdg* rdg, rdpTls* tls, const char* peerAddress, i
        {
                if (!proxy_connect(settings, bufferedBio, proxyUsername, proxyPassword, settings->GatewayHostname,
                                   settings->GatewayPort))
+               {
+                       BIO_free_all(bufferedBio);
                        return FALSE;
+               }
        }
 
        if (!status)
index 08813b2..54f35a4 100644 (file)
@@ -672,7 +672,7 @@ static BOOL rpc_channel_tls_connect(RpcChannel* channel, int timeout)
 
        if (!socketBio)
        {
-               close(sockfd);
+               closesocket(sockfd);
                return FALSE;
        }