fix memleak: free con->name before overwriting it
This commit is contained in:
parent
bdbda20293
commit
80ecd157f6
|
@ -49,6 +49,7 @@ void tree_init() {
|
||||||
Output *output;
|
Output *output;
|
||||||
|
|
||||||
croot = con_new(NULL);
|
croot = con_new(NULL);
|
||||||
|
FREE(croot->name);
|
||||||
croot->name = "root";
|
croot->name = "root";
|
||||||
croot->type = CT_ROOT;
|
croot->type = CT_ROOT;
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ void tree_init() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Con *oc = con_new(croot);
|
Con *oc = con_new(croot);
|
||||||
|
FREE(oc->name);
|
||||||
oc->name = strdup(output->name);
|
oc->name = strdup(output->name);
|
||||||
oc->type = CT_OUTPUT;
|
oc->type = CT_OUTPUT;
|
||||||
oc->rect = output->rect;
|
oc->rect = output->rect;
|
||||||
|
@ -74,6 +76,7 @@ void tree_init() {
|
||||||
ws = con_new(NULL);
|
ws = con_new(NULL);
|
||||||
ws->type = CT_WORKSPACE;
|
ws->type = CT_WORKSPACE;
|
||||||
ws->num = c;
|
ws->num = c;
|
||||||
|
FREE(ws->name);
|
||||||
asprintf(&(ws->name), "%d", c);
|
asprintf(&(ws->name), "%d", c);
|
||||||
c++;
|
c++;
|
||||||
con_attach(ws, oc, false);
|
con_attach(ws, oc, false);
|
||||||
|
|
|
@ -46,7 +46,8 @@ Con *workspace_get(const char *num) {
|
||||||
x_set_name(workspace, name);
|
x_set_name(workspace, name);
|
||||||
free(name);
|
free(name);
|
||||||
workspace->type = CT_WORKSPACE;
|
workspace->type = CT_WORKSPACE;
|
||||||
workspace->name = strdup(num);
|
FREE(workspace->name);
|
||||||
|
workspace->name = sstrdup(num);
|
||||||
/* We set ->num to the number if this workspace’s name consists only of
|
/* We set ->num to the number if this workspace’s name consists only of
|
||||||
* a positive number. Otherwise it’s a named ws and num will be -1. */
|
* a positive number. Otherwise it’s a named ws and num will be -1. */
|
||||||
char *end;
|
char *end;
|
||||||
|
|
Loading…
Reference in New Issue