Permalink
Browse files

libfreerdp-core: cleanup memory management of secondary orders

  • Loading branch information...
1 parent 353376a commit a1f23d0f97cf88b1ef2b73b7757a09b67e43c60d @awakecoding awakecoding committed Jan 28, 2013
@@ -46,11 +46,11 @@ foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES})
set(CLIENT_STATIC_ENTRY_IMPORTS "${CLIENT_STATIC_ENTRY_IMPORTS}\n${${STATIC_ENTRY}_IMPORTS}")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\nconst STATIC_ENTRY CLIENT_${STATIC_ENTRY}_TABLE[] =\n{")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n${${STATIC_ENTRY}_TABLE}")
- set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n\t{ \"\", NULL }\n};")
+ set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n\t{ NULL, NULL }\n};")
set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"${STATIC_ENTRY}\", CLIENT_${STATIC_ENTRY}_TABLE },")
endforeach()
-set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"\", NULL }\n};")
+set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ NULL, NULL }\n};")
set(CLIENT_STATIC_ADDIN_TABLE "const STATIC_ADDIN_TABLE CLIENT_STATIC_ADDIN_TABLE[] =\n{")
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
@@ -358,7 +358,9 @@ void* freerdp_channels_load_static_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
}
}
else
+ {
return (void*) CLIENT_STATIC_ADDIN_TABLE[i].entry;
+ }
}
}
@@ -69,6 +69,12 @@
#define GDI_DPa 0x00A000C9 /* D = D & P */
#define GDI_PDxn 0x00A50065 /* D = D ^ ~P */
+#define GDI_DSxn 0x00990066
+#define GDI_PSDnox 0x002D060A
+#define GDI_PDSona 0x00100C85
+#define GDI_DSPDxox 0x00740646
+#define GDI_DPSDonox 0x005B18A9
+
#define GDI_DPon 0x000500A9
#define GDI_DPna 0x000A0329
#define GDI_Pn 0x000F0001
@@ -147,7 +147,7 @@ struct _CACHE_GLYPH_ORDER
{
UINT32 cacheId;
UINT32 cGlyphs;
- GLYPH_DATA* glyphData[255];
+ GLYPH_DATA glyphData[255];
BYTE* unicodeCharacters;
};
typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER;
@@ -169,7 +169,7 @@ struct _CACHE_GLYPH_V2_ORDER
UINT32 cacheId;
UINT32 flags;
UINT32 cGlyphs;
- GLYPH_DATA_V2* glyphData[255];
+ GLYPH_DATA_V2 glyphData[255];
BYTE* unicodeCharacters;
};
typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER;
@@ -182,7 +182,7 @@ struct _CACHE_BRUSH_ORDER
UINT32 cy;
UINT32 style;
UINT32 length;
- BYTE* data;
+ BYTE data[256];
};
typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER;
View
@@ -75,8 +75,16 @@ void update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
{
+ int length;
+ void* data = NULL;
rdpCache* cache = context->cache;
- brush_cache_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
+
+ length = cache_brush->bpp * 64 / 8;
+
+ data = malloc(length);
+ CopyMemory(data, cache_brush->data, length);
+
+ brush_cache_put(cache->brush, cache_brush->index, data, cache_brush->bpp);
}
void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
View
@@ -312,7 +312,7 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
for (i = 0; i < (int) cache_glyph->cGlyphs; i++)
{
- glyph_data = cache_glyph->glyphData[i];
+ glyph_data = &cache_glyph->glyphData[i];
glyph = Glyph_Alloc(context);
@@ -325,9 +325,6 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, glyph);
-
- cache_glyph->glyphData[i] = NULL;
- free(glyph_data);
}
}
@@ -340,7 +337,7 @@ void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_
for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
{
- glyph_data = cache_glyph_v2->glyphData[i];
+ glyph_data = &cache_glyph_v2->glyphData[i];
glyph = Glyph_Alloc(context);
@@ -353,9 +350,6 @@ void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph);
-
- cache_glyph_v2->glyphData[i] = NULL;
- free(glyph_data);
}
}
View
@@ -48,6 +48,7 @@ void update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_s
default:
printf("Unknown system pointer type (0x%08X)\n", pointer_system->type);
+ break;
}
}
@@ -92,8 +93,20 @@ void update_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* pointer_new)
pointer->height = pointer_new->colorPtrAttr.height;
pointer->lengthAndMask = pointer_new->colorPtrAttr.lengthAndMask;
pointer->lengthXorMask = pointer_new->colorPtrAttr.lengthXorMask;
- pointer->xorMaskData = pointer_new->colorPtrAttr.xorMaskData;
- pointer->andMaskData = pointer_new->colorPtrAttr.andMaskData;
+
+ pointer->andMaskData = pointer->xorMaskData = NULL;
+
+ if (pointer->lengthAndMask)
+ {
+ pointer->andMaskData = (BYTE*) malloc(pointer->lengthAndMask);
+ CopyMemory(pointer->andMaskData, pointer_new->colorPtrAttr.andMaskData, pointer->lengthAndMask);
+ }
+
+ if (pointer->lengthXorMask)
+ {
+ pointer->xorMaskData = (BYTE*) malloc(pointer->lengthXorMask);
+ CopyMemory(pointer->xorMaskData, pointer_new->colorPtrAttr.xorMaskData, pointer->lengthXorMask);
+ }
pointer->New(context, pointer);
pointer_cache_put(cache->pointer, pointer_new->colorPtrAttr.cacheIndex, pointer);
@@ -215,11 +215,15 @@ ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const
void freerdp_static_channel_collection_free(rdpSettings* settings)
{
- int index;
+ int i, j;
- for (index = 0; index < settings->StaticChannelCount; index++)
+ for (i = 0; i < settings->StaticChannelCount; i++)
{
- free(settings->StaticChannelArray[index]);
+ for (j = 0; j < settings->StaticChannelArray[i]->argc; j++)
+ free(settings->StaticChannelArray[i]->argv[j]);
+
+ free(settings->StaticChannelArray[i]->argv);
+ free(settings->StaticChannelArray[i]);
}
free(settings->StaticChannelArray);
View
@@ -460,7 +460,7 @@ static void message_CacheBitmapV2(rdpContext* context, CACHE_BITMAP_V2_ORDER* ca
CopyMemory(wParam, cacheBitmapV2Order, sizeof(CACHE_BITMAP_V2_ORDER));
wParam->bitmapDataStream = (BYTE*) malloc(wParam->bitmapLength);
- CopyMemory(wParam->bitmapDataStream, cacheBitmapV2Order, wParam->bitmapLength);
+ CopyMemory(wParam->bitmapDataStream, cacheBitmapV2Order->bitmapDataStream, wParam->bitmapLength);
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheBitmapV2), (void*) wParam, NULL);
@@ -496,36 +496,22 @@ static void message_CacheColorTable(rdpContext* context, CACHE_COLOR_TABLE_ORDER
static void message_CacheGlyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyphOrder)
{
- int index;
CACHE_GLYPH_ORDER* wParam;
wParam = (CACHE_GLYPH_ORDER*) malloc(sizeof(CACHE_GLYPH_ORDER));
CopyMemory(wParam, cacheGlyphOrder, sizeof(CACHE_GLYPH_ORDER));
- for (index = 0; index < wParam->cGlyphs; index++)
- {
- wParam->glyphData[index] = (GLYPH_DATA*) malloc(sizeof(GLYPH_DATA));
- CopyMemory(wParam->glyphData[index], cacheGlyphOrder->glyphData[index], sizeof(GLYPH_DATA));
- }
-
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheGlyph), (void*) wParam, NULL);
}
static void message_CacheGlyphV2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order)
{
- int index;
CACHE_GLYPH_V2_ORDER* wParam;
wParam = (CACHE_GLYPH_V2_ORDER*) malloc(sizeof(CACHE_GLYPH_V2_ORDER));
CopyMemory(wParam, cacheGlyphV2Order, sizeof(CACHE_GLYPH_V2_ORDER));
- for (index = 0; index < wParam->cGlyphs; index++)
- {
- wParam->glyphData[index] = (GLYPH_DATA_V2*) malloc(sizeof(GLYPH_DATA_V2));
- CopyMemory(wParam->glyphData[index], cacheGlyphV2Order->glyphData[index], sizeof(GLYPH_DATA_V2));
- }
-
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheGlyphV2), (void*) wParam, NULL);
}
@@ -537,9 +523,6 @@ static void message_CacheBrush(rdpContext* context, CACHE_BRUSH_ORDER* cacheBrus
wParam = (CACHE_BRUSH_ORDER*) malloc(sizeof(CACHE_BRUSH_ORDER));
CopyMemory(wParam, cacheBrushOrder, sizeof(CACHE_BRUSH_ORDER));
- //wParam->data = (BYTE*) malloc(wParam->length);
- //CopyMemory(wParam->data, cacheBrushOrder->data, wParam->length);
-
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheBrush), (void*) wParam, NULL);
}
@@ -1192,7 +1175,7 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
{
CACHE_BITMAP_V2_ORDER* wParam = (CACHE_BITMAP_V2_ORDER*) msg->wParam;
- //free(wParam->bitmapDataStream);
+ free(wParam->bitmapDataStream);
free(wParam);
}
break;
@@ -1220,25 +1203,15 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
case SecondaryUpdate_CacheGlyph:
IFCALL(update->CacheGlyph, msg->context, (CACHE_GLYPH_ORDER*) msg->wParam);
{
- int index;
CACHE_GLYPH_ORDER* wParam = (CACHE_GLYPH_ORDER*) msg->wParam;
-
- for (index = 0; index < wParam->cGlyphs; index++)
- free(wParam->glyphData[index]);
-
free(wParam);
}
break;
case SecondaryUpdate_CacheGlyphV2:
IFCALL(update->CacheGlyphV2, msg->context, (CACHE_GLYPH_V2_ORDER*) msg->wParam);
{
- int index;
CACHE_GLYPH_V2_ORDER* wParam = (CACHE_GLYPH_V2_ORDER*) msg->wParam;
-
- for (index = 0; index < wParam->cGlyphs; index++)
- free(wParam->glyphData[index]);
-
free(wParam);
}
break;
@@ -1247,8 +1220,6 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
IFCALL(update->CacheBrush, msg->context, (CACHE_BRUSH_ORDER*) msg->wParam);
{
CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*) msg->wParam;
-
- //free(wParam->data);
free(wParam);
}
break;
@@ -1445,8 +1416,8 @@ int message_process_pointer_update_class(rdpMessage* update, wMessage* msg, int
{
POINTER_COLOR_UPDATE* wParam = (POINTER_COLOR_UPDATE*) msg->wParam;
- //free(wParam->andMaskData);
- //free(wParam->xorMaskData);
+ free(wParam->andMaskData);
+ free(wParam->xorMaskData);
free(wParam);
}
break;
@@ -1456,8 +1427,8 @@ int message_process_pointer_update_class(rdpMessage* update, wMessage* msg, int
{
POINTER_NEW_UPDATE* wParam = (POINTER_NEW_UPDATE*) msg->wParam;
- //free(wParam->colorPtrAttr.andMaskData);
- //free(wParam->colorPtrAttr.xorMaskData);
+ free(wParam->colorPtrAttr.andMaskData);
+ free(wParam->colorPtrAttr.xorMaskData);
free(wParam);
}
break;
Oops, something went wrong.

0 comments on commit a1f23d0

Please sign in to comment.