From 3c44ff9c8398f624540d5103d9e67a38213e2ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 6 Nov 2013 14:31:33 -0500 Subject: [PATCH] channels/rdpsnd: fix bug in rdpsnd and rdpdr deinitialization --- channels/rdpsnd/client/rdpsnd_main.c | 64 ++++++++----------- .../utils/collections/ListDictionary.c | 2 +- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 4706cf99f..08495c043 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -740,31 +740,6 @@ static void rdpsnd_process_connect(rdpsndPlugin* rdpsnd) } } -static void rdpsnd_process_terminate(rdpsndPlugin* rdpsnd) -{ - if (rdpsnd->device) - IFCALL(rdpsnd->device->Free, rdpsnd->device); - - MessageQueue_PostQuit(rdpsnd->MsgPipe->Out, 0); - - WaitForSingleObject(rdpsnd->ScheduleThread, INFINITE); - CloseHandle(rdpsnd->ScheduleThread); - - if (rdpsnd->subsystem) - free(rdpsnd->subsystem); - - if (rdpsnd->device_name) - free(rdpsnd->device_name); - - rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats); - rdpsnd->NumberOfServerFormats = 0; - rdpsnd->ServerFormats = NULL; - - rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats); - rdpsnd->NumberOfClientFormats = 0; - rdpsnd->ClientFormats = NULL; -} - /****************************************************************************************/ @@ -951,26 +926,41 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, void* p (LPTHREAD_START_ROUTINE) rdpsnd_virtual_channel_client_thread, (void*) plugin, 0, NULL); } -static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* plugin) +static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd) { - MessagePipe_PostQuit(plugin->MsgPipe, 0); - WaitForSingleObject(plugin->thread, INFINITE); + MessagePipe_PostQuit(rdpsnd->MsgPipe, 0); + WaitForSingleObject(rdpsnd->thread, INFINITE); - MessagePipe_Free(plugin->MsgPipe); - CloseHandle(plugin->thread); + MessagePipe_Free(rdpsnd->MsgPipe); + CloseHandle(rdpsnd->thread); - plugin->channelEntryPoints.pVirtualChannelClose(plugin->OpenHandle); + rdpsnd->channelEntryPoints.pVirtualChannelClose(rdpsnd->OpenHandle); - if (plugin->data_in) + if (rdpsnd->data_in) { - Stream_Free(plugin->data_in, TRUE); - plugin->data_in = NULL; + Stream_Free(rdpsnd->data_in, TRUE); + rdpsnd->data_in = NULL; } - rdpsnd_process_terminate(plugin); + if (rdpsnd->device) + IFCALL(rdpsnd->device->Free, rdpsnd->device); - rdpsnd_remove_open_handle_data(plugin->OpenHandle); - rdpsnd_remove_init_handle_data(plugin->InitHandle); + if (rdpsnd->subsystem) + free(rdpsnd->subsystem); + + if (rdpsnd->device_name) + free(rdpsnd->device_name); + + rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats); + rdpsnd->NumberOfServerFormats = 0; + rdpsnd->ServerFormats = NULL; + + rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats); + rdpsnd->NumberOfClientFormats = 0; + rdpsnd->ClientFormats = NULL; + + rdpsnd_remove_open_handle_data(rdpsnd->OpenHandle); + rdpsnd_remove_init_handle_data(rdpsnd->InitHandle); } static void rdpsnd_virtual_channel_init_event(void* pInitHandle, UINT32 event, void* pData, UINT32 dataLength) diff --git a/winpr/libwinpr/utils/collections/ListDictionary.c b/winpr/libwinpr/utils/collections/ListDictionary.c index d1df02125..bef4f0757 100644 --- a/winpr/libwinpr/utils/collections/ListDictionary.c +++ b/winpr/libwinpr/utils/collections/ListDictionary.c @@ -206,7 +206,7 @@ void ListDictionary_Clear(wListDictionary* listDictionary) { nextItem = item->next; if (listDictionary->object.fnObjectFree) - listDictionary->object.fnObjectFree(item); + listDictionary->object.fnObjectFree(item->value); free(item); item = nextItem; }