From: Orestis Floros Date: Sun, 25 Mar 2018 17:23:46 +0000 (+0300) Subject: cfg_workspace: memleak on duplicate workspace assignment X-Git-Tag: 4.16~115^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a5014dc7f84fb820929b36264d058491ecbace93;p=i3%2Fi3 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. --- 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) {