From 8dda26af541f1d007a1be75288cadd5031ab952d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 30 Dec 2019 16:11:13 -0800 Subject: [PATCH] GUACAMOLE-249: Free rdpBitmap and rdpGlyph within custom free handlers (not automatically freed like rdpPointer). --- src/protocols/rdp/bitmap.c | 7 +++++++ src/protocols/rdp/glyph.c | 7 +++++++ src/protocols/rdp/pointer.c | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/protocols/rdp/bitmap.c b/src/protocols/rdp/bitmap.c index 56d80e35..f0c499ad 100644 --- a/src/protocols/rdp/bitmap.c +++ b/src/protocols/rdp/bitmap.c @@ -156,6 +156,13 @@ void guac_rdp_bitmap_free(rdpContext* context, rdpBitmap* bitmap) { if (buffer != NULL) guac_common_display_free_buffer(rdp_client->display, buffer); + /* NOTE: FreeRDP-allocated memory for the rdpBitmap will NOT be + * automatically released after this free handler is invoked, thus we must + * do so manually here */ + + _aligned_free(bitmap->data); + free(bitmap); + } BOOL guac_rdp_bitmap_setsurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary) { diff --git a/src/protocols/rdp/glyph.c b/src/protocols/rdp/glyph.c index 6a0aaab8..576149b8 100644 --- a/src/protocols/rdp/glyph.c +++ b/src/protocols/rdp/glyph.c @@ -121,6 +121,13 @@ void guac_rdp_glyph_free(rdpContext* context, rdpGlyph* glyph) { cairo_surface_destroy(((guac_rdp_glyph*) glyph)->surface); free(image_buffer); + /* NOTE: FreeRDP-allocated memory for the rdpGlyph will NOT be + * automatically released after this free handler is invoked, thus we must + * do so manually here */ + + free(glyph->aj); + free(glyph); + } BOOL guac_rdp_glyph_begindraw(rdpContext* context, INT32 x, INT32 y, diff --git a/src/protocols/rdp/pointer.c b/src/protocols/rdp/pointer.c index 498bc883..079637bb 100644 --- a/src/protocols/rdp/pointer.c +++ b/src/protocols/rdp/pointer.c @@ -95,6 +95,9 @@ void guac_rdp_pointer_free(rdpContext* context, rdpPointer* pointer) { /* Free buffer */ guac_common_display_free_buffer(rdp_client->display, buffer); + /* NOTE: FreeRDP-allocated memory for the rdpPointer will be automatically + * released after this free handler is invoked */ + } BOOL guac_rdp_pointer_set_null(rdpContext* context) {