libfreerdp-core: improve handling of create offscreen bitmap delete list indices

This commit is contained in:
Marc-André Moreau 2011-12-31 15:36:04 -05:00
parent 845d6ead55
commit 3a3db9f20c
3 changed files with 17 additions and 4 deletions

View File

@ -38,6 +38,7 @@
struct _OFFSCREEN_DELETE_LIST
{
uint32 sIndices;
uint32 cIndices;
uint16* indices;
};

View File

@ -1498,10 +1498,11 @@ void update_read_create_offscreen_bitmap_order(STREAM* s, CREATE_OFFSCREEN_BITMA
stream_read_uint16(s, deleteList->cIndices);
if (deleteList->indices == NULL)
deleteList->indices = xmalloc(deleteList->cIndices * 2);
else
deleteList->indices = xrealloc(deleteList->indices, deleteList->cIndices * 2);
if (deleteList->cIndices > deleteList->sIndices)
{
deleteList->sIndices = deleteList->cIndices;
deleteList->indices = xrealloc(deleteList->indices, deleteList->sIndices * 2);
}
for (i = 0; i < (int) deleteList->cIndices; i++)
{

View File

@ -543,6 +543,8 @@ rdpUpdate* update_new(rdpRdp* rdp)
if (update != NULL)
{
OFFSCREEN_DELETE_LIST* deleteList;
update->bitmap_update.count = 64;
update->bitmap_update.rectangles = (BITMAP_DATA*) xzalloc(sizeof(BITMAP_DATA) * update->bitmap_update.count);
@ -551,6 +553,11 @@ rdpUpdate* update_new(rdpRdp* rdp)
update->secondary = xnew(rdpSecondaryUpdate);
update->altsec = xnew(rdpAltSecUpdate);
update->window = xnew(rdpWindowUpdate);
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
deleteList->sIndices = 64;
deleteList->indices = xmalloc(deleteList->sIndices * 2);
deleteList->cIndices = 0;
}
return update;
@ -560,6 +567,10 @@ void update_free(rdpUpdate* update)
{
if (update != NULL)
{
OFFSCREEN_DELETE_LIST* deleteList;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
xfree(deleteList->indices);
xfree(update->bitmap_update.rectangles);
xfree(update->pointer);
xfree(update->primary);