From 64ad42b95b1c40a9a8d7aa73e334681374890d16 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 12 May 2020 14:26:45 +0200 Subject: [PATCH] Fixed DestroyListener arguments and call order --- channels/audin/client/audin_main.c | 6 ++++-- channels/disp/client/disp_main.c | 2 +- channels/drdynvc/client/drdynvc_main.c | 21 +++++++++------------ channels/echo/client/echo_main.c | 5 +++-- channels/geometry/client/geometry_main.c | 2 +- channels/rdpei/client/rdpei_main.c | 2 +- channels/rdpgfx/client/rdpgfx_main.c | 2 +- channels/rdpsnd/client/rdpsnd_main.c | 2 +- channels/urbdrc/client/urbdrc_main.c | 4 ++-- channels/urbdrc/client/urbdrc_main.h | 1 + channels/video/client/video_main.c | 4 ++-- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index d843b21f5..26ac48390 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -100,6 +100,8 @@ struct _AUDIN_PLUGIN FREERDP_DSP_CONTEXT* dsp_context; wLog* log; + + IWTSListener* listener; }; static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args); @@ -687,7 +689,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag audin->listener_callback->plugin = pPlugin; audin->listener_callback->channel_mgr = pChannelMgr; return pChannelMgr->CreateListener(pChannelMgr, "AUDIO_INPUT", 0, - &audin->listener_callback->iface, NULL); + &audin->listener_callback->iface, &audin->listener); } /** @@ -709,7 +711,7 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = audin->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &audin->iface); + IFCALL(mgr->DestroyListener, mgr, audin->listener); } audio_formats_free(audin->fixed_format, 1); diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index 58a902a30..fa92c252a 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -326,7 +326,7 @@ static UINT disp_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = disp->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &disp->iface); + IFCALL(mgr->DestroyListener, mgr, disp->listener); } free(disp->listener_callback); diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 93de13318..e28483c08 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -40,6 +40,7 @@ static void dvcman_wtslistener_free(DVCMAN_LISTENER* listener) { if (listener) free(listener->channel_name); + free(listener); } @@ -217,6 +218,11 @@ static void dvcman_plugin_terminate(void* plugin) WLog_ERR(TAG, "Terminated failed with error %" PRIu32 "!", error); } +static void wts_listener_free(void* arg) +{ + DVCMAN_LISTENER* listener = (DVCMAN_LISTENER*)arg; + dvcman_wtslistener_free(listener); +} static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) { wObject* obj; @@ -248,7 +254,7 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) if (!dvcman->listeners) goto fail; obj = ArrayList_Object(dvcman->listeners); - obj->fnObjectFree = dvcman_wtslistener_free; + obj->fnObjectFree = wts_listener_free; dvcman->plugin_names = ArrayList_New(TRUE); if (!dvcman->plugin_names) @@ -378,10 +384,10 @@ static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan { DVCMAN* dvcman = (DVCMAN*)pChannelMgr; - ArrayList_Free(dvcman->listeners); + ArrayList_Free(dvcman->plugins); ArrayList_Free(dvcman->channels); ArrayList_Free(dvcman->plugin_names); - ArrayList_Free(dvcman->plugins); + ArrayList_Free(dvcman->listeners); StreamPool_Free(dvcman->pool); free(dvcman); @@ -580,7 +586,6 @@ static UINT dvcman_open_channel(drdynvcPlugin* drdynvc, IWTSVirtualChannelManage static UINT dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, BOOL bSendClosePDU) { - size_t i; DVCMAN_CHANNEL* channel; UINT error = CHANNEL_RC_OK; DVCMAN* dvcman = (DVCMAN*)pChannelMgr; @@ -614,14 +619,6 @@ static UINT dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 } } - ArrayList_Lock(dvcman->listeners); - for (i = ArrayList_Count(dvcman->listeners); i > 0; i--) - { - DVCMAN_LISTENER* listener = ArrayList_GetItem(dvcman->listeners, i - 1); - if (strcmp(listener->channel_name, channel->channel_name) == 0) - ArrayList_Remove(dvcman->listeners, listener); - } - ArrayList_Unlock(dvcman->listeners); ArrayList_Remove(dvcman->channels, channel); return error; } diff --git a/channels/echo/client/echo_main.c b/channels/echo/client/echo_main.c index 83f27f94d..c8dc4d8a5 100644 --- a/channels/echo/client/echo_main.c +++ b/channels/echo/client/echo_main.c @@ -59,6 +59,7 @@ struct _ECHO_PLUGIN IWTSPlugin iface; ECHO_LISTENER_CALLBACK* listener_callback; + IWTSListener* listener; }; /** @@ -143,7 +144,7 @@ static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage echo->listener_callback->channel_mgr = pChannelMgr; return pChannelMgr->CreateListener(pChannelMgr, "ECHO", 0, &echo->listener_callback->iface, - NULL); + &echo->listener); } /** @@ -158,7 +159,7 @@ static UINT echo_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = echo->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &echo->iface); + IFCALL(mgr->DestroyListener, mgr, echo->listener); } free(echo); diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index d3373e0c4..eb65b2ca2 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -431,7 +431,7 @@ static UINT geometry_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = geometry->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &geometry->iface); + IFCALL(mgr->DestroyListener, mgr, geometry->listener); } if (context) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 82f56aec1..0a0cfefb2 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -601,7 +601,7 @@ static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = rdpei->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &rdpei->iface); + IFCALL(mgr->DestroyListener, mgr, rdpei->listener); } free(rdpei->listener_callback); free(rdpei->context); diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index e8591a017..5c5ec4933 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -1916,7 +1916,7 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = gfx->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &gfx->iface); + IFCALL(mgr->DestroyListener, mgr, gfx->listener); } rdpgfx_client_context_free(context); return CHANNEL_RC_OK; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 3f400a55f..9318c95c6 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1560,7 +1560,7 @@ static UINT rdpsnd_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = rdpsnd->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &rdpsnd->iface); + IFCALL(mgr->DestroyListener, mgr, rdpsnd->listener); } free(rdpsnd->listener_callback); free(rdpsnd->iface.pInterface); diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index b6449cd47..5c8483b0f 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -687,7 +687,7 @@ static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana /* [MS-RDPEUSB] 2.1 Transport defines the channel name in uppercase letters */ CharUpperA(channelName); status = pChannelMgr->CreateListener(pChannelMgr, channelName, 0, - &urbdrc->listener_callback->iface, NULL); + &urbdrc->listener_callback->iface, &urbdrc->listener); if (status != CHANNEL_RC_OK) return status; @@ -713,7 +713,7 @@ static UINT urbdrc_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = urbdrc->listener_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &urbdrc->iface); + IFCALL(mgr->DestroyListener, mgr, urbdrc->listener); } udevman = urbdrc->udevman; diff --git a/channels/urbdrc/client/urbdrc_main.h b/channels/urbdrc/client/urbdrc_main.h index 2a750d64d..2b643f7cb 100644 --- a/channels/urbdrc/client/urbdrc_main.h +++ b/channels/urbdrc/client/urbdrc_main.h @@ -84,6 +84,7 @@ struct _URBDRC_PLUGIN char* subsystem; wLog* log; + IWTSListener* listener; }; typedef BOOL (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman); diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c index 3fecb63a7..9a68d92d3 100644 --- a/channels/video/client/video_main.c +++ b/channels/video/client/video_main.c @@ -1088,13 +1088,13 @@ static UINT video_plugin_terminated(IWTSPlugin* pPlugin) { IWTSVirtualChannelManager* mgr = video->control_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &video->control_callback->iface); + IFCALL(mgr->DestroyListener, mgr, video->controlListener); } if (video->data_callback) { IWTSVirtualChannelManager* mgr = video->data_callback->channel_mgr; if (mgr) - IFCALL(mgr->DestroyListener, mgr, &video->data_callback->iface); + IFCALL(mgr->DestroyListener, mgr, video->dataListener); } if (video->context)