Merge pull request #187 from atong-tcs/master

libfreerdp-cache: fix leak with child bitmap reuse
This commit is contained in:
Marc-André Moreau 2011-10-26 09:42:17 -07:00
commit c8ff653451

View File

@ -81,11 +81,13 @@ void update_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap_update)
rdpBitmap* bitmap;
BITMAP_DATA* bitmap_data;
rdpCache* cache = update->context->cache;
int reused = 1;
if (cache->bitmap->bitmap == NULL)
{
cache->bitmap->bitmap = Bitmap_Alloc(update->context);
cache->bitmap->bitmap->ephemeral = True;
reused = 0;
}
bitmap = cache->bitmap->bitmap;
@ -107,6 +109,11 @@ void update_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap_update)
bitmap_data->bitmapDataStream, bitmap_data->width, bitmap_data->height,
bitmap_data->bitsPerPixel, bitmap_data->bitmapLength, bitmap_data->compressed);
if (reused)
bitmap->Free(update->context, bitmap);
else
reused = 1;
bitmap->New(update->context, bitmap);
bitmap->Paint(update->context, bitmap);