diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index cae4c649a..c0053c569 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -319,7 +319,9 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) if (!dvcman->channelsById) goto fail; - HashTable_SetHashFunction(dvcman->channelsById, channelIdHash); + if (!HashTable_SetHashFunction(dvcman->channelsById, channelIdHash)) + goto fail; + obj = HashTable_KeyObject(dvcman->channelsById); WINPR_ASSERT(obj); obj->fnObjectEquals = channelIdMatch; @@ -335,7 +337,9 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) dvcman->listeners = HashTable_New(TRUE); if (!dvcman->listeners) goto fail; - HashTable_SetHashFunction(dvcman->listeners, HashTable_StringHash); + + if (!HashTable_SetHashFunction(dvcman->listeners, HashTable_StringHash)) + goto fail; obj = HashTable_KeyObject(dvcman->listeners); obj->fnObjectEquals = HashTable_StringCompare; diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index 1c4f96ad4..ef7ea1887 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -346,31 +346,43 @@ static const IWTSVirtualChannelCallback geometry_callbacks = { geometry_on_data_ nullptr, /* Open */ geometry_on_close, nullptr }; +static void geometry_plugin_free(GeometryClientContext* context) +{ + if (!context) + return; + HashTable_Free(context->geometries); + free(context); +} +static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) +{ + GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base; + + if (!geometry) + return; + + geometry_plugin_free(geometry->context); +} + static UINT init_plugin_cb(GENERIC_DYNVC_PLUGIN* base, WINPR_ATTR_UNUSED rdpContext* rcontext, rdpSettings* settings) { - GeometryClientContext* context = nullptr; GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base; WINPR_ASSERT(base); WINPR_UNUSED(settings); - context = (GeometryClientContext*)calloc(1, sizeof(GeometryClientContext)); + GeometryClientContext* context = + (GeometryClientContext*)calloc(1, sizeof(GeometryClientContext)); if (!context) - { - WLog_Print(base->log, WLOG_ERROR, "calloc failed!"); - return CHANNEL_RC_NO_MEMORY; - } + goto fail; context->geometries = HashTable_New(FALSE); if (!context->geometries) - { - WLog_Print(base->log, WLOG_ERROR, "unable to allocate geometries"); - free(context); - return CHANNEL_RC_NO_MEMORY; - } + goto fail; + + if (!HashTable_SetHashFunction(context->geometries, mappedGeometryHash)) + goto fail; - HashTable_SetHashFunction(context->geometries, mappedGeometryHash); { wObject* obj = HashTable_KeyObject(context->geometries); obj->fnObjectEquals = mappedGeometryKeyCompare; @@ -385,15 +397,10 @@ static UINT init_plugin_cb(GENERIC_DYNVC_PLUGIN* base, WINPR_ATTR_UNUSED rdpCont geometry->base.iface.pInterface = (void*)context; return CHANNEL_RC_OK; -} -static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) -{ - GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base; - - if (geometry->context) - HashTable_Free(geometry->context->geometries); - free(geometry->context); +fail: + geometry_plugin_free(context); + return CHANNEL_RC_NO_MEMORY; } /** diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 630b373c6..32c04ce51 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -3707,7 +3707,8 @@ static RdpdrServerPrivate* rdpdr_server_private_new(void) if (!priv->devicelist) goto fail; - HashTable_SetHashFunction(priv->devicelist, rdpdr_deviceid_hash); + if (!HashTable_SetHashFunction(priv->devicelist, rdpdr_deviceid_hash)) + goto fail; { wObject* obj = HashTable_ValueObject(priv->devicelist);