From 0e5034b02a346d97a7e27e8609e760a070473a48 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 22 Jun 2018 11:41:26 +0200 Subject: [PATCH] Fix X11 memoryleak for round corners When using round corners, the shape_gc in x_win_round_corners never got freed. This created a memory leak in x11 itself and let the X process create more load while becoming sluggish in some situations. From the docs, XFreeGC actually could return an int and could throw a BadGC error. Neither of them are important to catch in our situation: - Having a look into the Xlib sourcecode, XFreeGC returns always 1. - As we don't overwrite the shape_gc or do any other destoying calls, the BadGC can't happen in this code. --- src/x11/x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/x11/x.c b/src/x11/x.c index bda92e5..504851c 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -141,6 +141,7 @@ static void x_win_round_corners(window_x11 *win, const int rad) XShapeCombineMask(xctx.dpy, win->xwin, ShapeBounding, 0, 0, mask, ShapeSet); + XFreeGC(xctx.dpy, shape_gc); XFreePixmap(xctx.dpy, mask); XShapeSelectInput(xctx.dpy,