diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index efd29faba..bd3e75b6a 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1062,8 +1062,17 @@ void transport_free(rdpTransport* transport) { if (transport->async) { - assert(!transport->thread); - assert(!transport->stopEvent); + if (transport->stopEvent) + { + SetEvent(transport->stopEvent); + WaitForSingleObject(transport->thread, INFINITE); + + CloseHandle(transport->thread); + CloseHandle(transport->stopEvent); + + transport->thread = NULL; + transport->stopEvent = NULL; + } } if (transport->ReceiveBuffer)