mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[channels,rdpdr] clone key values for device list
the supplied key value might be allocated on stack, so create a copy that is valid as long as the entry.
This commit is contained in:
@@ -124,6 +124,24 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void* rdpdr_device_key_clone(const void* pvval)
|
||||
{
|
||||
const UINT32* val = pvval;
|
||||
if (!val)
|
||||
return NULL;
|
||||
|
||||
UINT32* ptr = calloc(1, sizeof(UINT32));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
*ptr = *val;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void rdpdr_device_key_free(void* obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
static RdpdrDevice* rdpdr_get_device_by_id(RdpdrServerPrivate* priv, UINT32 DeviceId)
|
||||
{
|
||||
WINPR_ASSERT(priv);
|
||||
@@ -3556,6 +3574,8 @@ static RdpdrServerPrivate* rdpdr_server_private_new(void)
|
||||
|
||||
obj = HashTable_KeyObject(priv->devicelist);
|
||||
obj->fnObjectEquals = rdpdr_device_equal;
|
||||
obj->fnObjectFree = rdpdr_device_key_free;
|
||||
obj->fnObjectNew = rdpdr_device_key_clone;
|
||||
|
||||
return priv;
|
||||
fail:
|
||||
|
||||
Reference in New Issue
Block a user