[core,cache] fixed default pointer and bitmap new
do not overwrite pointer or bitmap data in New callback
This commit is contained in:
parent
d66b165b8e
commit
b0c924a98e
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;
|
||||
|
@ -43,15 +43,6 @@ rdpBitmap* Bitmap_Alloc(rdpContext* context)
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static BOOL Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
|
||||
{
|
||||
if (!bitmap || !context)
|
||||
return FALSE;
|
||||
|
||||
*bitmap = *context->graphics->Bitmap_Prototype;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
|
||||
{
|
||||
if (bitmap)
|
||||
@ -107,18 +98,6 @@ rdpPointer* Pointer_Alloc(rdpContext* context)
|
||||
return pointer;
|
||||
}
|
||||
|
||||
static BOOL Pointer_New(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
rdpPointer* proto;
|
||||
|
||||
if (!context || !context->graphics || !context->graphics->Pointer_Prototype)
|
||||
return FALSE;
|
||||
|
||||
proto = context->graphics->Pointer_Prototype;
|
||||
*pointer = *proto;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* static method */
|
||||
void graphics_register_pointer(rdpGraphics* graphics, const rdpPointer* pointer)
|
||||
{
|
||||
@ -204,8 +183,6 @@ rdpGraphics* graphics_new(rdpContext* context)
|
||||
}
|
||||
|
||||
graphics->Bitmap_Prototype->size = sizeof(rdpBitmap);
|
||||
graphics->Bitmap_Prototype->New = Bitmap_New;
|
||||
graphics->Bitmap_Prototype->Free = NULL;
|
||||
graphics->Pointer_Prototype = (rdpPointer*)calloc(1, sizeof(rdpPointer));
|
||||
|
||||
if (!graphics->Pointer_Prototype)
|
||||
@ -216,8 +193,6 @@ rdpGraphics* graphics_new(rdpContext* context)
|
||||
}
|
||||
|
||||
graphics->Pointer_Prototype->size = sizeof(rdpPointer);
|
||||
graphics->Pointer_Prototype->New = Pointer_New;
|
||||
graphics->Pointer_Prototype->Free = NULL;
|
||||
graphics->Glyph_Prototype = (rdpGlyph*)calloc(1, sizeof(rdpGlyph));
|
||||
|
||||
if (!graphics->Glyph_Prototype)
|
||||
|
Loading…
Reference in New Issue
Block a user