mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[core,cache] fixed default pointer and bitmap new
do not overwrite pointer or bitmap data in New callback
This commit is contained in:
60
libfreerdp/cache/pointer.c
vendored
60
libfreerdp/cache/pointer.c
vendored
@@ -36,26 +36,28 @@ static BOOL pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index, rdpP
|
||||
BOOL colorCache);
|
||||
static rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index);
|
||||
|
||||
static void pointer_clear(rdpPointer* pointer)
|
||||
{
|
||||
if (pointer)
|
||||
{
|
||||
pointer->lengthAndMask = 0;
|
||||
free(pointer->andMaskData);
|
||||
pointer->andMaskData = NULL;
|
||||
|
||||
pointer->lengthXorMask = 0;
|
||||
free(pointer->xorMaskData);
|
||||
pointer->xorMaskData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void pointer_free(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
if (pointer)
|
||||
{
|
||||
IFCALL(pointer->Free, context, pointer);
|
||||
|
||||
if (pointer->xorMaskData)
|
||||
{
|
||||
free(pointer->xorMaskData);
|
||||
pointer->xorMaskData = NULL;
|
||||
}
|
||||
|
||||
if (pointer->andMaskData)
|
||||
{
|
||||
free(pointer->andMaskData);
|
||||
pointer->andMaskData = NULL;
|
||||
}
|
||||
|
||||
free(pointer);
|
||||
pointer_clear(pointer);
|
||||
}
|
||||
free(pointer);
|
||||
}
|
||||
|
||||
static BOOL update_pointer_position(rdpContext* context,
|
||||
@@ -104,30 +106,25 @@ static BOOL upate_pointer_copy_andxor(rdpPointer* pointer, const BYTE* andMaskDa
|
||||
size_t lengthAndMask, const BYTE* xorMaskData,
|
||||
size_t lengthXorMask)
|
||||
{
|
||||
pointer->lengthAndMask = 0;
|
||||
pointer->lengthXorMask = 0;
|
||||
|
||||
WINPR_ASSERT(pointer);
|
||||
|
||||
pointer_clear(pointer);
|
||||
if (lengthAndMask && andMaskData)
|
||||
{
|
||||
BYTE* tmp;
|
||||
pointer->lengthAndMask = lengthAndMask;
|
||||
tmp = (BYTE*)realloc(pointer->andMaskData, lengthAndMask);
|
||||
if (!tmp)
|
||||
pointer->andMaskData = (BYTE*)malloc(lengthAndMask);
|
||||
if (!pointer->andMaskData)
|
||||
return FALSE;
|
||||
pointer->andMaskData = tmp;
|
||||
|
||||
CopyMemory(pointer->andMaskData, andMaskData, lengthAndMask);
|
||||
}
|
||||
|
||||
if (lengthXorMask && xorMaskData)
|
||||
{
|
||||
BYTE* tmp;
|
||||
pointer->lengthXorMask = lengthXorMask;
|
||||
tmp = (BYTE*)realloc(pointer->xorMaskData, lengthXorMask);
|
||||
if (!tmp)
|
||||
pointer->xorMaskData = (BYTE*)malloc(lengthXorMask);
|
||||
if (!pointer->xorMaskData)
|
||||
return FALSE;
|
||||
pointer->xorMaskData = tmp;
|
||||
|
||||
CopyMemory(pointer->xorMaskData, xorMaskData, lengthXorMask);
|
||||
}
|
||||
@@ -167,10 +164,8 @@ static BOOL update_pointer_color(rdpContext* context, const POINTER_COLOR_UPDATE
|
||||
if (!pointer_cache_put(cache->pointer, pointer_color->cacheIndex, pointer, TRUE))
|
||||
goto out_fail;
|
||||
|
||||
if (!IFCALLRESULT(TRUE, pointer->Set, context, pointer))
|
||||
goto out_fail;
|
||||
return IFCALLRESULT(TRUE, pointer->Set, context, pointer);
|
||||
|
||||
return TRUE;
|
||||
out_fail:
|
||||
pointer_free(context, pointer);
|
||||
return FALSE;
|
||||
@@ -207,10 +202,8 @@ static BOOL update_pointer_large(rdpContext* context, const POINTER_LARGE_UPDATE
|
||||
if (!pointer_cache_put(cache->pointer, pointer_large->cacheIndex, pointer, FALSE))
|
||||
goto out_fail;
|
||||
|
||||
if (!IFCALLRESULT(TRUE, pointer->Set, context, pointer))
|
||||
goto out_fail;
|
||||
return IFCALLRESULT(TRUE, pointer->Set, context, pointer);
|
||||
|
||||
return TRUE;
|
||||
out_fail:
|
||||
pointer_free(context, pointer);
|
||||
return FALSE;
|
||||
@@ -246,9 +239,8 @@ static BOOL update_pointer_new(rdpContext* context, const POINTER_NEW_UPDATE* po
|
||||
if (!pointer_cache_put(cache->pointer, pointer_new->colorPtrAttr.cacheIndex, pointer, FALSE))
|
||||
goto out_fail;
|
||||
|
||||
if (!IFCALLRESULT(TRUE, pointer->Set, context, pointer))
|
||||
goto out_fail;
|
||||
return TRUE;
|
||||
return IFCALLRESULT(TRUE, pointer->Set, context, pointer);
|
||||
|
||||
out_fail:
|
||||
pointer_free(context, pointer);
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user