Skip to content

Commit

Permalink
Merge pull request #168 from msharov/master
Browse files Browse the repository at this point in the history
Fix memory leak in ewmh_set_desktop_names
  • Loading branch information
JLErvin authored Jan 14, 2022
2 parents 538de11 + bb93de7 commit 2212ff2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,17 +2298,15 @@ static void ewmh_set_client_list(void)
*/
static void ewmh_set_desktop_names(void)
{
char **list;
char** list = calloc(WORKSPACE_NUMBER, sizeof(char*));
for (int i = 0; i < WORKSPACE_NUMBER; i++)
asprintf(&list[i], "%d", i);
XTextProperty text_prop;
list = malloc(sizeof(char*) * WORKSPACE_NUMBER);
for (int i = 0; i < WORKSPACE_NUMBER; i++) {
char *tmp = malloc(sizeof(char) * 2 + 1);
sprintf(tmp, "%d", i);
list[i] = tmp;
}
Xutf8TextListToTextProperty(display, list, WORKSPACE_NUMBER, XUTF8StringStyle, &text_prop);
XSetTextProperty(display, root, &text_prop, XInternAtom(display, "_NET_DESKTOP_NAMES", False));
XFree(text_prop.value);
for (int i = 0; i < WORKSPACE_NUMBER; i++)
free(list[i]);
free(list);
}

Expand Down

0 comments on commit 2212ff2

Please sign in to comment.