Merge pull request #30 from glyptodon/bitmap-memory-leak

GUAC-1095: Free any existing bitmap data prior to overwriting the bitmap data pointer.
This commit is contained in:
James Muehlner 2015-02-23 21:05:41 -08:00
commit 9b72370399

View File

@ -201,8 +201,17 @@ void guac_rdp_bitmap_decompress(rdpContext* context, rdpBitmap* bitmap, UINT8* d
int size = width * height * 4; int size = width * height * 4;
#ifdef FREERDP_BITMAP_REQUIRES_ALIGNED_MALLOC #ifdef FREERDP_BITMAP_REQUIRES_ALIGNED_MALLOC
/* Free pre-existing data, if any (might be reused) */
if (bitmap->data != NULL)
_aligned_free(bitmap->data);
/* Allocate new data */
bitmap->data = (UINT8*) _aligned_malloc(size, 16); bitmap->data = (UINT8*) _aligned_malloc(size, 16);
#else #else
/* Free pre-existing data, if any (might be reused) */
free(bitmap->data);
/* Allocate new data */
bitmap->data = (UINT8*) malloc(size); bitmap->data = (UINT8*) malloc(size);
#endif #endif