From f429b909a9a0785ae46c0268432547753c2b9d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 26 Nov 2013 11:30:44 -0500 Subject: [PATCH] libfreerdp-core: fix transport_free in cases where transport thread was not started --- libfreerdp/core/transport.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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)