From 7c0a33632b3e585d4f6f722f07c8bd64378b4571 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 12 Feb 2018 10:02:35 +0100 Subject: [PATCH] Fixed #4412: XImage must be freed with XDestroyImage --- client/X11/xf_gdi.c | 6 +++--- client/X11/xf_gfx.c | 4 ++-- client/X11/xf_graphics.c | 4 ++-- rdtk/sample/rdtk_x11.c | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 68f3641f8..50a22cc62 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -245,7 +245,7 @@ static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height, image->bitmap_bit_order = LSBFirst; gc = XCreateGC(xfc->display, xfc->drawable, 0, NULL); XPutImage(xfc->display, bitmap, gc, image, 0, 0, 0, 0, width, height); - XFree(image); + XDestroyImage(image); if (cdata != data) _aligned_free(cdata); @@ -269,7 +269,7 @@ static Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height, image->byte_order = LSBFirst; image->bitmap_bit_order = LSBFirst; XPutImage(xfc->display, bitmap, xfc->gc_mono, image, 0, 0, 0, 0, width, height); - XFree(image); + XDestroyImage(image); return bitmap; } @@ -1028,7 +1028,7 @@ static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData, image->bitmap_bit_order = LSBFirst; XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0, left, top, width, height); - XFree(image); + XDestroyImage(image); ret = xf_gdi_surface_update_frame(xfc, left, top, width, height); } diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c index 330596b61..5ac6a24e3 100644 --- a/client/X11/xf_gfx.c +++ b/client/X11/xf_gfx.c @@ -310,7 +310,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context, return CHANNEL_RC_OK; error_set_surface_data: - XFree(surface->image); + XDestroyImage(surface->image); error_surface_image: _aligned_free(surface->stage); out_free_gdidata: @@ -338,7 +338,7 @@ static UINT xf_DeleteSurface(RdpgfxClientContext* context, #ifdef WITH_GFX_H264 h264_context_free(surface->gdi.h264); #endif - XFree(surface->image); + XDestroyImage(surface->image); _aligned_free(surface->gdi.data); _aligned_free(surface->stage); region16_uninit(&surface->gdi.invalidRegion); diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index c2ef117af..6893b3b49 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -174,7 +174,7 @@ static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap) XFreePixmap(xfc->display, xbitmap->pixmap); if (xbitmap->image) - XFree(xbitmap->image); + XDestroyImage(xbitmap->image); xf_unlock_x11(xfc, FALSE); } @@ -397,7 +397,7 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph) XInitImage(image); XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0, glyph->cx, glyph->cy); - XFree(image); + XDestroyImage(image); xf_unlock_x11(xfc, FALSE); return TRUE; } diff --git a/rdtk/sample/rdtk_x11.c b/rdtk/sample/rdtk_x11.c index dbe8c2787..4282fd848 100644 --- a/rdtk/sample/rdtk_x11.c +++ b/rdtk/sample/rdtk_x11.c @@ -142,7 +142,9 @@ int main(int argc, char** argv) } XFlush(display); - + + XDestroyImage(image); + XFreePixmap(display, pixmap); XCloseDisplay(display); rdtk_surface_free(surface);