From 5ff1dc2b8f6ec0ab2ebdd132ba1b56cebeb9626c Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Wed, 18 Mar 2020 19:47:55 +0100 Subject: Plug a memory leak in conf_clear These loops never freed cargs and cargs->cmd from bind_ctx. Instead of adding more calls to free() manually, replace the whole loops with the conf_unbind_* functions which free the struct properly. --- conf.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/conf.c b/conf.c index aa7d55c..6f66ba4 100644 --- a/conf.c +++ b/conf.c @@ -320,7 +320,6 @@ void conf_clear(struct conf *c) { struct autogroup *ag; - struct bind_ctx *kb, *mb; struct winname *wn; struct cmd_ctx *cmd, *wm; int i; @@ -337,10 +336,7 @@ conf_clear(struct conf *c) free(wm->path); free(wm); } - while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) { - TAILQ_REMOVE(&c->keybindq, kb, entry); - free(kb); - } + conf_unbind_key(c, NULL); while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) { TAILQ_REMOVE(&c->autogroupq, ag, entry); free(ag->class); @@ -352,10 +348,7 @@ conf_clear(struct conf *c) free(wn->name); free(wn); } - while ((mb = TAILQ_FIRST(&c->mousebindq)) != NULL) { - TAILQ_REMOVE(&c->mousebindq, mb, entry); - free(mb); - } + conf_unbind_mouse(c, NULL); for (i = 0; i < CWM_COLOR_NITEMS; i++) free(c->color[i]); -- cgit v1.2.3-2-gb3c3