[channels] Check HashTable_SetHashFunction return

This commit is contained in:
Armin Novak
2026-03-02 12:31:32 +01:00
parent 56f4337220
commit b909b0cf1c
3 changed files with 35 additions and 23 deletions

View File

@@ -319,7 +319,9 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
if (!dvcman->channelsById) if (!dvcman->channelsById)
goto fail; goto fail;
HashTable_SetHashFunction(dvcman->channelsById, channelIdHash); if (!HashTable_SetHashFunction(dvcman->channelsById, channelIdHash))
goto fail;
obj = HashTable_KeyObject(dvcman->channelsById); obj = HashTable_KeyObject(dvcman->channelsById);
WINPR_ASSERT(obj); WINPR_ASSERT(obj);
obj->fnObjectEquals = channelIdMatch; obj->fnObjectEquals = channelIdMatch;
@@ -335,7 +337,9 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
dvcman->listeners = HashTable_New(TRUE); dvcman->listeners = HashTable_New(TRUE);
if (!dvcman->listeners) if (!dvcman->listeners)
goto fail; goto fail;
HashTable_SetHashFunction(dvcman->listeners, HashTable_StringHash);
if (!HashTable_SetHashFunction(dvcman->listeners, HashTable_StringHash))
goto fail;
obj = HashTable_KeyObject(dvcman->listeners); obj = HashTable_KeyObject(dvcman->listeners);
obj->fnObjectEquals = HashTable_StringCompare; obj->fnObjectEquals = HashTable_StringCompare;

View File

@@ -346,31 +346,43 @@ static const IWTSVirtualChannelCallback geometry_callbacks = { geometry_on_data_
nullptr, /* Open */ nullptr, /* Open */
geometry_on_close, nullptr }; 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, static UINT init_plugin_cb(GENERIC_DYNVC_PLUGIN* base, WINPR_ATTR_UNUSED rdpContext* rcontext,
rdpSettings* settings) rdpSettings* settings)
{ {
GeometryClientContext* context = nullptr;
GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base; GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base;
WINPR_ASSERT(base); WINPR_ASSERT(base);
WINPR_UNUSED(settings); WINPR_UNUSED(settings);
context = (GeometryClientContext*)calloc(1, sizeof(GeometryClientContext)); GeometryClientContext* context =
(GeometryClientContext*)calloc(1, sizeof(GeometryClientContext));
if (!context) if (!context)
{ goto fail;
WLog_Print(base->log, WLOG_ERROR, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
}
context->geometries = HashTable_New(FALSE); context->geometries = HashTable_New(FALSE);
if (!context->geometries) if (!context->geometries)
{ goto fail;
WLog_Print(base->log, WLOG_ERROR, "unable to allocate geometries");
free(context); if (!HashTable_SetHashFunction(context->geometries, mappedGeometryHash))
return CHANNEL_RC_NO_MEMORY; goto fail;
}
HashTable_SetHashFunction(context->geometries, mappedGeometryHash);
{ {
wObject* obj = HashTable_KeyObject(context->geometries); wObject* obj = HashTable_KeyObject(context->geometries);
obj->fnObjectEquals = mappedGeometryKeyCompare; 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; geometry->base.iface.pInterface = (void*)context;
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
}
static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) fail:
{ geometry_plugin_free(context);
GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)base; return CHANNEL_RC_NO_MEMORY;
if (geometry->context)
HashTable_Free(geometry->context->geometries);
free(geometry->context);
} }
/** /**

View File

@@ -3707,7 +3707,8 @@ static RdpdrServerPrivate* rdpdr_server_private_new(void)
if (!priv->devicelist) if (!priv->devicelist)
goto fail; 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); wObject* obj = HashTable_ValueObject(priv->devicelist);