Fixed rdg bio cleanup.

When attaching the RDG BIO to the TLS BIO also transfer ownership.
This commit is contained in:
Armin Novak 2018-11-13 12:22:09 +01:00
parent 3c35a098f5
commit ecac998340
3 changed files with 9 additions and 7 deletions

View File

@ -108,6 +108,7 @@ struct rdp_rdg
{
rdpContext* context;
rdpSettings* settings;
BOOL attached;
BIO* frontBio;
rdpTls* tlsIn;
rdpTls* tlsOut;
@ -1544,15 +1545,19 @@ void rdg_free(rdpRdg* rdg)
tls_free(rdg->tlsIn);
http_context_free(rdg->http);
ntlm_free(rdg->ntlm);
BIO_free_all(rdg->frontBio);
if (!rdg->attached)
BIO_free_all(rdg->frontBio);
DeleteCriticalSection(&rdg->writeSection);
free(rdg);
}
BIO* rdg_front_bio(rdpRdg* rdg)
BIO* rdg_get_front_bio_and_take_ownership(rdpRdg* rdg)
{
if (!rdg)
return NULL;
rdg->attached = TRUE;
return rdg->frontBio;
}

View File

@ -43,7 +43,7 @@ typedef struct rdp_rdg rdpRdg;
FREERDP_LOCAL rdpRdg* rdg_new(rdpContext* context);
FREERDP_LOCAL void rdg_free(rdpRdg* rdg);
FREERDP_LOCAL BIO* rdg_front_bio(rdpRdg* rdg);
FREERDP_LOCAL BIO* rdg_get_front_bio_and_take_ownership(rdpRdg* rdg);
FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, int timeout, BOOL* rpcFallback);
FREERDP_LOCAL DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events,

View File

@ -378,7 +378,7 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname,
if (status)
{
transport->frontBio = rdg_front_bio(transport->rdg);
transport->frontBio = rdg_get_front_bio_and_take_ownership(transport->rdg);
BIO_set_nonblock(transport->frontBio, 0);
transport->layer = TRANSPORT_LAYER_TSG;
status = TRUE;
@ -1093,9 +1093,6 @@ BOOL transport_disconnect(rdpTransport* transport)
if (!transport)
return FALSE;
if (transport->rdg && (rdg_front_bio(transport->rdg) == transport->frontBio))
transport->frontBio = NULL;
if (transport->tls)
{
tls_free(transport->tls);