From 824b2cb8858b19ace3e26a0f54cf9dd740be9b59 Mon Sep 17 00:00:00 2001 From: blk_750 Date: Fri, 19 May 2023 13:17:02 +0000 Subject: [PATCH] fix: memory leak in `win_draw_bar` (#444) Closes: https://codeberg.org/nsxiv/nsxiv/issues/410 Co-authored-by: blk_750 Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/444 Reviewed-by: NRK Co-authored-by: blk_750 Co-committed-by: blk_750 --- window.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/window.c b/window.c index 3857871..b170614 100644 --- a/window.c +++ b/window.c @@ -470,8 +470,10 @@ static void win_draw_bar(win_t *win) XSetBackground(e->dpy, gc, win->bar_bg.pixel); if ((len = strlen(r->buf)) > 0) { - if ((tw = TEXTWIDTH(win, r->buf, len)) > w) + if ((tw = TEXTWIDTH(win, r->buf, len)) > w) { + XftDrawDestroy(d); return; + } x = win->w - tw - H_TEXT_PAD; w -= tw; win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw);