libfreerdp-core: cleanup memory management of secondary orders

This commit is contained in:
Marc-André Moreau 2013-01-28 18:42:32 -05:00
parent 353376abd3
commit a1f23d0f97
11 changed files with 81 additions and 70 deletions

View File

@ -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_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}\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${${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 },") set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"${STATIC_ENTRY}\", CLIENT_${STATIC_ENTRY}_TABLE },")
endforeach() 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{") set(CLIENT_STATIC_ADDIN_TABLE "const STATIC_ADDIN_TABLE CLIENT_STATIC_ADDIN_TABLE[] =\n{")
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES}) foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})

View File

@ -358,9 +358,11 @@ void* freerdp_channels_load_static_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
} }
} }
else else
{
return (void*) CLIENT_STATIC_ADDIN_TABLE[i].entry; return (void*) CLIENT_STATIC_ADDIN_TABLE[i].entry;
} }
} }
}
return NULL; return NULL;
} }

View File

@ -69,6 +69,12 @@
#define GDI_DPa 0x00A000C9 /* D = D & P */ #define GDI_DPa 0x00A000C9 /* D = D & P */
#define GDI_PDxn 0x00A50065 /* 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_DPon 0x000500A9
#define GDI_DPna 0x000A0329 #define GDI_DPna 0x000A0329
#define GDI_Pn 0x000F0001 #define GDI_Pn 0x000F0001

View File

@ -147,7 +147,7 @@ struct _CACHE_GLYPH_ORDER
{ {
UINT32 cacheId; UINT32 cacheId;
UINT32 cGlyphs; UINT32 cGlyphs;
GLYPH_DATA* glyphData[255]; GLYPH_DATA glyphData[255];
BYTE* unicodeCharacters; BYTE* unicodeCharacters;
}; };
typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER; typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER;
@ -169,7 +169,7 @@ struct _CACHE_GLYPH_V2_ORDER
UINT32 cacheId; UINT32 cacheId;
UINT32 flags; UINT32 flags;
UINT32 cGlyphs; UINT32 cGlyphs;
GLYPH_DATA_V2* glyphData[255]; GLYPH_DATA_V2 glyphData[255];
BYTE* unicodeCharacters; BYTE* unicodeCharacters;
}; };
typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER; typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER;
@ -182,7 +182,7 @@ struct _CACHE_BRUSH_ORDER
UINT32 cy; UINT32 cy;
UINT32 style; UINT32 style;
UINT32 length; UINT32 length;
BYTE* data; BYTE data[256];
}; };
typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER; typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER;

View File

@ -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) void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
{ {
int length;
void* data = NULL;
rdpCache* cache = context->cache; 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) void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)

View File

@ -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++) 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); 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_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, 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++) 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); 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_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph); glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph);
cache_glyph_v2->glyphData[i] = NULL;
free(glyph_data);
} }
} }

View File

@ -48,6 +48,7 @@ void update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_s
default: default:
printf("Unknown system pointer type (0x%08X)\n", pointer_system->type); 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->height = pointer_new->colorPtrAttr.height;
pointer->lengthAndMask = pointer_new->colorPtrAttr.lengthAndMask; pointer->lengthAndMask = pointer_new->colorPtrAttr.lengthAndMask;
pointer->lengthXorMask = pointer_new->colorPtrAttr.lengthXorMask; 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->New(context, pointer);
pointer_cache_put(cache->pointer, pointer_new->colorPtrAttr.cacheIndex, pointer); pointer_cache_put(cache->pointer, pointer_new->colorPtrAttr.cacheIndex, pointer);

View File

@ -215,11 +215,15 @@ ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const
void freerdp_static_channel_collection_free(rdpSettings* settings) 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); free(settings->StaticChannelArray);

View File

@ -460,7 +460,7 @@ static void message_CacheBitmapV2(rdpContext* context, CACHE_BITMAP_V2_ORDER* ca
CopyMemory(wParam, cacheBitmapV2Order, sizeof(CACHE_BITMAP_V2_ORDER)); CopyMemory(wParam, cacheBitmapV2Order, sizeof(CACHE_BITMAP_V2_ORDER));
wParam->bitmapDataStream = (BYTE*) malloc(wParam->bitmapLength); 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, MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheBitmapV2), (void*) wParam, NULL); 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) static void message_CacheGlyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyphOrder)
{ {
int index;
CACHE_GLYPH_ORDER* wParam; CACHE_GLYPH_ORDER* wParam;
wParam = (CACHE_GLYPH_ORDER*) malloc(sizeof(CACHE_GLYPH_ORDER)); wParam = (CACHE_GLYPH_ORDER*) malloc(sizeof(CACHE_GLYPH_ORDER));
CopyMemory(wParam, cacheGlyphOrder, 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, MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheGlyph), (void*) wParam, NULL); MakeMessageId(SecondaryUpdate, CacheGlyph), (void*) wParam, NULL);
} }
static void message_CacheGlyphV2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order) static void message_CacheGlyphV2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order)
{ {
int index;
CACHE_GLYPH_V2_ORDER* wParam; CACHE_GLYPH_V2_ORDER* wParam;
wParam = (CACHE_GLYPH_V2_ORDER*) malloc(sizeof(CACHE_GLYPH_V2_ORDER)); wParam = (CACHE_GLYPH_V2_ORDER*) malloc(sizeof(CACHE_GLYPH_V2_ORDER));
CopyMemory(wParam, cacheGlyphV2Order, 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, MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheGlyphV2), (void*) wParam, NULL); 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)); wParam = (CACHE_BRUSH_ORDER*) malloc(sizeof(CACHE_BRUSH_ORDER));
CopyMemory(wParam, cacheBrushOrder, 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, MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(SecondaryUpdate, CacheBrush), (void*) wParam, NULL); 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; CACHE_BITMAP_V2_ORDER* wParam = (CACHE_BITMAP_V2_ORDER*) msg->wParam;
//free(wParam->bitmapDataStream); free(wParam->bitmapDataStream);
free(wParam); free(wParam);
} }
break; break;
@ -1220,12 +1203,7 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
case SecondaryUpdate_CacheGlyph: case SecondaryUpdate_CacheGlyph:
IFCALL(update->CacheGlyph, msg->context, (CACHE_GLYPH_ORDER*) msg->wParam); IFCALL(update->CacheGlyph, msg->context, (CACHE_GLYPH_ORDER*) msg->wParam);
{ {
int index;
CACHE_GLYPH_ORDER* wParam = (CACHE_GLYPH_ORDER*) msg->wParam; CACHE_GLYPH_ORDER* wParam = (CACHE_GLYPH_ORDER*) msg->wParam;
for (index = 0; index < wParam->cGlyphs; index++)
free(wParam->glyphData[index]);
free(wParam); free(wParam);
} }
break; break;
@ -1233,12 +1211,7 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
case SecondaryUpdate_CacheGlyphV2: case SecondaryUpdate_CacheGlyphV2:
IFCALL(update->CacheGlyphV2, msg->context, (CACHE_GLYPH_V2_ORDER*) msg->wParam); IFCALL(update->CacheGlyphV2, msg->context, (CACHE_GLYPH_V2_ORDER*) msg->wParam);
{ {
int index;
CACHE_GLYPH_V2_ORDER* wParam = (CACHE_GLYPH_V2_ORDER*) msg->wParam; CACHE_GLYPH_V2_ORDER* wParam = (CACHE_GLYPH_V2_ORDER*) msg->wParam;
for (index = 0; index < wParam->cGlyphs; index++)
free(wParam->glyphData[index]);
free(wParam); free(wParam);
} }
break; 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); IFCALL(update->CacheBrush, msg->context, (CACHE_BRUSH_ORDER*) msg->wParam);
{ {
CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*) msg->wParam; CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*) msg->wParam;
//free(wParam->data);
free(wParam); free(wParam);
} }
break; 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; POINTER_COLOR_UPDATE* wParam = (POINTER_COLOR_UPDATE*) msg->wParam;
//free(wParam->andMaskData); free(wParam->andMaskData);
//free(wParam->xorMaskData); free(wParam->xorMaskData);
free(wParam); free(wParam);
} }
break; 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; POINTER_NEW_UPDATE* wParam = (POINTER_NEW_UPDATE*) msg->wParam;
//free(wParam->colorPtrAttr.andMaskData); free(wParam->colorPtrAttr.andMaskData);
//free(wParam->colorPtrAttr.xorMaskData); free(wParam->colorPtrAttr.xorMaskData);
free(wParam); free(wParam);
} }
break; break;

View File

@ -1269,19 +1269,17 @@ BOOL update_read_cache_glyph_order(STREAM* s, CACHE_GLYPH_ORDER* cache_glyph_ord
if (stream_get_left(s) < 2) if (stream_get_left(s) < 2)
return FALSE; return FALSE;
stream_read_BYTE(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */ stream_read_BYTE(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */
stream_read_BYTE(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */ stream_read_BYTE(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */
for (i = 0; i < (int) cache_glyph_order->cGlyphs; i++) for (i = 0; i < (int) cache_glyph_order->cGlyphs; i++)
{ {
if (cache_glyph_order->glyphData[i] == NULL) glyph = &cache_glyph_order->glyphData[i];
{
cache_glyph_order->glyphData[i] = (GLYPH_DATA*) malloc(sizeof(GLYPH_DATA));
}
glyph = cache_glyph_order->glyphData[i];
if (stream_get_left(s) < 10) if (stream_get_left(s) < 10)
return FALSE; return FALSE;
stream_read_UINT16(s, glyph->cacheIndex); stream_read_UINT16(s, glyph->cacheIndex);
stream_read_UINT16(s, lsi16); stream_read_UINT16(s, lsi16);
glyph->x = lsi16; glyph->x = lsi16;
@ -1295,13 +1293,16 @@ BOOL update_read_cache_glyph_order(STREAM* s, CACHE_GLYPH_ORDER* cache_glyph_ord
if (stream_get_left(s) < glyph->cb) if (stream_get_left(s) < glyph->cb)
return FALSE; return FALSE;
glyph->aj = (BYTE*) malloc(glyph->cb); glyph->aj = (BYTE*) malloc(glyph->cb);
stream_read(s, glyph->aj, glyph->cb); stream_read(s, glyph->aj, glyph->cb);
} }
if (flags & CG_GLYPH_UNICODE_PRESENT) { if (flags & CG_GLYPH_UNICODE_PRESENT)
{
return stream_skip(s, cache_glyph_order->cGlyphs * 2); return stream_skip(s, cache_glyph_order->cGlyphs * 2);
} }
return TRUE; return TRUE;
} }
@ -1316,14 +1317,11 @@ BOOL update_read_cache_glyph_v2_order(STREAM* s, CACHE_GLYPH_V2_ORDER* cache_gly
for (i = 0; i < (int) cache_glyph_v2_order->cGlyphs; i++) for (i = 0; i < (int) cache_glyph_v2_order->cGlyphs; i++)
{ {
if (cache_glyph_v2_order->glyphData[i] == NULL) glyph = &cache_glyph_v2_order->glyphData[i];
{
cache_glyph_v2_order->glyphData[i] = (GLYPH_DATA_V2*) malloc(sizeof(GLYPH_DATA_V2));
}
glyph = cache_glyph_v2_order->glyphData[i];
if (stream_get_left(s) < 1) if (stream_get_left(s) < 1)
return FALSE; return FALSE;
stream_read_BYTE(s, glyph->cacheIndex); stream_read_BYTE(s, glyph->cacheIndex);
if (!update_read_2byte_signed(s, &glyph->x) || if (!update_read_2byte_signed(s, &glyph->x) ||
@ -1339,13 +1337,16 @@ BOOL update_read_cache_glyph_v2_order(STREAM* s, CACHE_GLYPH_V2_ORDER* cache_gly
if (stream_get_left(s) < glyph->cb) if (stream_get_left(s) < glyph->cb)
return FALSE; return FALSE;
glyph->aj = (BYTE*) malloc(glyph->cb); glyph->aj = (BYTE*) malloc(glyph->cb);
stream_read(s, glyph->aj, glyph->cb); stream_read(s, glyph->aj, glyph->cb);
} }
if (flags & CG_GLYPH_UNICODE_PRESENT) { if (flags & CG_GLYPH_UNICODE_PRESENT)
{
return stream_skip(s, cache_glyph_v2_order->cGlyphs * 2); return stream_skip(s, cache_glyph_v2_order->cGlyphs * 2);
} }
return TRUE; return TRUE;
} }
@ -1390,6 +1391,7 @@ BOOL update_read_cache_brush_order(STREAM* s, CACHE_BRUSH_ORDER* cache_brush_ord
if (stream_get_left(s) < 6) if (stream_get_left(s) < 6)
return FALSE; return FALSE;
stream_read_BYTE(s, cache_brush_order->index); /* cacheEntry (1 byte) */ stream_read_BYTE(s, cache_brush_order->index); /* cacheEntry (1 byte) */
stream_read_BYTE(s, iBitmapFormat); /* iBitmapFormat (1 byte) */ stream_read_BYTE(s, iBitmapFormat); /* iBitmapFormat (1 byte) */
@ -1404,8 +1406,6 @@ BOOL update_read_cache_brush_order(STREAM* s, CACHE_BRUSH_ORDER* cache_brush_ord
{ {
size = (cache_brush_order->bpp == 1) ? 8 : 8 * 8 * cache_brush_order->bpp; size = (cache_brush_order->bpp == 1) ? 8 : 8 * 8 * cache_brush_order->bpp;
cache_brush_order->data = (BYTE*) malloc(size);
if (cache_brush_order->bpp == 1) if (cache_brush_order->bpp == 1)
{ {
if (cache_brush_order->length != 8) if (cache_brush_order->length != 8)
@ -1442,6 +1442,7 @@ BOOL update_read_cache_brush_order(STREAM* s, CACHE_BRUSH_ORDER* cache_brush_ord
{ {
/* uncompressed brush */ /* uncompressed brush */
int scanline = (cache_brush_order->bpp / 8) * 8; int scanline = (cache_brush_order->bpp / 8) * 8;
if (stream_get_left(s) < scanline * 8) if (stream_get_left(s) < scanline * 8)
return FALSE; return FALSE;
@ -1452,6 +1453,7 @@ BOOL update_read_cache_brush_order(STREAM* s, CACHE_BRUSH_ORDER* cache_brush_ord
} }
} }
} }
return TRUE; return TRUE;
} }

View File

@ -243,7 +243,12 @@ BOOL update_read_pointer_color(STREAM* s, POINTER_COLOR_UPDATE* pointer_color)
{ {
if (stream_get_left(s) < pointer_color->lengthXorMask) if (stream_get_left(s) < pointer_color->lengthXorMask)
return FALSE; return FALSE;
pointer_color->xorMaskData = (BYTE*) malloc(pointer_color->lengthXorMask);
if (!pointer_color->xorMaskData)
pointer_color->xorMaskData = malloc(pointer_color->lengthXorMask);
else
pointer_color->xorMaskData = realloc(pointer_color->xorMaskData, pointer_color->lengthXorMask);
stream_read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask); stream_read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask);
} }
@ -251,12 +256,18 @@ BOOL update_read_pointer_color(STREAM* s, POINTER_COLOR_UPDATE* pointer_color)
{ {
if (stream_get_left(s) < pointer_color->lengthAndMask) if (stream_get_left(s) < pointer_color->lengthAndMask)
return FALSE; return FALSE;
pointer_color->andMaskData = (BYTE*) malloc(pointer_color->lengthAndMask);
if (!pointer_color->andMaskData)
pointer_color->andMaskData = malloc(pointer_color->lengthAndMask);
else
pointer_color->andMaskData = realloc(pointer_color->andMaskData, pointer_color->lengthAndMask);
stream_read(s, pointer_color->andMaskData, pointer_color->lengthAndMask); stream_read(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
} }
if (stream_get_left(s) > 0) if (stream_get_left(s) > 0)
stream_seek_BYTE(s); /* pad (1 byte) */ stream_seek_BYTE(s); /* pad (1 byte) */
return TRUE; return TRUE;
} }