diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index 968b343d7..e1d73b2bf 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -157,7 +157,7 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg) UINT error = 0; DWORD status; - if (arg == NULL) + if (oss == NULL) { error = ERROR_INVALID_PARAMETER; goto err_out; diff --git a/libfreerdp/core/gateway/ncacn_http.c b/libfreerdp/core/gateway/ncacn_http.c index a1c891620..10813a8f6 100644 --- a/libfreerdp/core/gateway/ncacn_http.c +++ b/libfreerdp/core/gateway/ncacn_http.c @@ -44,6 +44,9 @@ static wStream* rpc_ntlm_http_request(HttpContext* http, const char* method, request = http_request_new(); + if (!request) + goto fail; + if (ntlmToken) base64NtlmToken = crypto_base64_encode(ntlmToken->pvBuffer, ntlmToken->cbBuffer); @@ -52,7 +55,7 @@ static wStream* rpc_ntlm_http_request(HttpContext* http, const char* method, if (!http_request_set_method(request, method) || !http_request_set_content_length(request, contentLength) || !http_request_set_uri(request, uri)) - return NULL; + goto fail; if (base64NtlmToken) { diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index b1bab4824..ca678cebc 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -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) diff --git a/libfreerdp/core/gateway/rpc.c b/libfreerdp/core/gateway/rpc.c index 81db7c228..54f35a4bc 100644 --- a/libfreerdp/core/gateway/rpc.c +++ b/libfreerdp/core/gateway/rpc.c @@ -671,24 +671,36 @@ static BOOL rpc_channel_tls_connect(RpcChannel* channel, int timeout) socketBio = BIO_new(BIO_s_simple_socket()); if (!socketBio) + { + closesocket(sockfd); return FALSE; + } BIO_set_fd(socketBio, sockfd, BIO_CLOSE); bufferedBio = BIO_new(BIO_s_buffered_socket()); if (!bufferedBio) + { + BIO_free_all(socketBio); return FALSE; + } bufferedBio = BIO_push(bufferedBio, socketBio); if (!BIO_set_nonblock(bufferedBio, TRUE)) + { + BIO_free_all(bufferedBio); return FALSE; + } if (channel->client->isProxy) { if (!proxy_connect(settings, bufferedBio, proxyUsername, proxyPassword, settings->GatewayHostname, settings->GatewayPort)) + { + BIO_free_all(bufferedBio); return FALSE; + } } channel->bio = bufferedBio; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 62b2777e1..9b186d654 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -224,22 +224,30 @@ wStream* transport_send_stream_init(rdpTransport* transport, int size) BOOL transport_attach(rdpTransport* transport, int sockfd) { - BIO* socketBio; + BIO* socketBio = NULL; BIO* bufferedBio; socketBio = BIO_new(BIO_s_simple_socket()); if (!socketBio) - return FALSE; + goto fail; BIO_set_fd(socketBio, sockfd, BIO_CLOSE); bufferedBio = BIO_new(BIO_s_buffered_socket()); if (!bufferedBio) - return FALSE; + goto fail; bufferedBio = BIO_push(bufferedBio, socketBio); transport->frontBio = bufferedBio; return TRUE; +fail: + + if (socketBio) + BIO_free_all(socketBio); + else + close(sockfd); + + return FALSE; } BOOL transport_connect_rdp(rdpTransport* transport) @@ -1093,7 +1101,7 @@ BOOL transport_disconnect(rdpTransport* transport) else { if (transport->frontBio) - BIO_free(transport->frontBio); + BIO_free_all(transport->frontBio); } if (transport->tsg)