From ee1f5511955316e6e6abdcaad427bc41cf8d53f0 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 25 Mar 2018 20:04:31 +0300 Subject: [PATCH 1/4] startup.c: free timer Small memleak. The timer is not called used again since ev_timer_init is called with repeat = 0. --- src/startup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/startup.c b/src/startup.c index 166842e0..1e733fcb 100644 --- a/src/startup.c +++ b/src/startup.c @@ -49,6 +49,7 @@ static void startup_timeout(EV_P_ ev_timer *w, int revents) { if (!sequence) { DLOG("Sequence already deleted, nevermind.\n"); + free(w); return; } From a5014dc7f84fb820929b36264d058491ecbace93 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 25 Mar 2018 20:23:46 +0300 Subject: [PATCH 2/4] cfg_workspace: memleak on duplicate workspace assignment assignment->output is set but lost since TAILQ_INSERT_TAIL is never called when duplicate is set. This essentially happens on every reload. --- src/config_directives.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/config_directives.c b/src/config_directives.c index da1fb580..491c840a 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -328,21 +328,18 @@ CFGFUN(workspace, const char *workspace, const char *output) { * don’t have assignments of a single workspace to different * outputs */ struct Workspace_Assignment *assignment; - bool duplicate = false; TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) { if (strcasecmp(assignment->name, workspace) == 0) { ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n", workspace); - assignment->output = sstrdup(output); - duplicate = true; + return; } } - if (!duplicate) { - assignment = scalloc(1, sizeof(struct Workspace_Assignment)); - assignment->name = sstrdup(workspace); - assignment->output = sstrdup(output); - TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); - } + + assignment = scalloc(1, sizeof(struct Workspace_Assignment)); + assignment->name = sstrdup(workspace); + assignment->output = sstrdup(output); + TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); } CFGFUN(ipc_socket, const char *path) { From e19a1209614a5cab8b66ca138ad24df2c0345244 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 25 Mar 2018 20:35:53 +0300 Subject: [PATCH 3/4] Free A_TO_WORKSPACE_NUMBER assignments --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index fd379fde..95b7ec98 100644 --- a/src/config.c +++ b/src/config.c @@ -99,7 +99,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, struct Assignment *assign; while (!TAILQ_EMPTY(&assignments)) { assign = TAILQ_FIRST(&assignments); - if (assign->type == A_TO_WORKSPACE) + if (assign->type == A_TO_WORKSPACE || assign->type == A_TO_WORKSPACE_NUMBER) FREE(assign->dest.workspace); else if (assign->type == A_COMMAND) FREE(assign->dest.command); From b0997234ab9b49c43aca5dcd3d15abda88de9877 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 25 Mar 2018 20:48:20 +0300 Subject: [PATCH 4/4] con_toggle_layout: free(tm_dup) outside loop --- src/con.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/con.c b/src/con.c index 480b9e9e..8953f0ed 100644 --- a/src/con.c +++ b/src/con.c @@ -1917,7 +1917,6 @@ void con_toggle_layout(Con *con, const char *toggle_mode) { * now let's activate the current layout (next in list) */ if (current_layout_found) { new_layout = layout; - free(tm_dup); break; } @@ -1925,6 +1924,7 @@ void con_toggle_layout(Con *con, const char *toggle_mode) { current_layout_found = true; } } + free(tm_dup); if (new_layout != L_DEFAULT) { con_set_layout(con, new_layout);