diff options
author | Dan Robertson <dan.robertson@anidata.org> | 2018-02-11 20:08:56 +0000 |
---|---|---|
committer | Dan Robertson <dan.robertson@anidata.org> | 2018-02-11 20:45:06 +0000 |
commit | 15f9c89e8427aa7cdf97061a2bda89d8403e4fba (patch) | |
tree | 53af848863a7a5d0ecc13d87c270ff960272aaeb | |
parent | Merge pull request #1591 from dlrobertson/fix_mem_errors (diff) | |
download | sway-15f9c89e8427aa7cdf97061a2bda89d8403e4fba.tar.gz sway-15f9c89e8427aa7cdf97061a2bda89d8403e4fba.tar.zst sway-15f9c89e8427aa7cdf97061a2bda89d8403e4fba.zip |
Fix more leaks
- get_parent_pid: free buffer returned from read_line after use.
- workspace_for_pid: ensure free_pid_workspace is called when
pid_workspaces are removed from config->pid_workspaces.
- cmd_split: return the cmd_results from _do_split, so that the
parent function may free it.
-rw-r--r-- | common/util.c | 1 | ||||
-rw-r--r-- | sway/commands/split.c | 9 | ||||
-rw-r--r-- | sway/workspace.c | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/common/util.c b/common/util.c index d6369853..38ac9367 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -96,6 +96,7 @@ pid_t get_parent_pid(pid_t child) { | |||
96 | parent = strtol(token, NULL, 10); | 96 | parent = strtol(token, NULL, 10); |
97 | } | 97 | } |
98 | 98 | ||
99 | free(buffer); | ||
99 | fclose(stat); | 100 | fclose(stat); |
100 | } | 101 | } |
101 | 102 | ||
diff --git a/sway/commands/split.c b/sway/commands/split.c index e3045a4f..1624eebe 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -62,22 +62,21 @@ struct cmd_results *cmd_split(int argc, char **argv) { | |||
62 | return error; | 62 | return error; |
63 | } | 63 | } |
64 | if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { | 64 | if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { |
65 | _do_split(argc - 1, argv + 1, L_VERT); | 65 | return _do_split(argc - 1, argv + 1, L_VERT); |
66 | } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { | 66 | } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { |
67 | _do_split(argc - 1, argv + 1, L_HORIZ); | 67 | return _do_split(argc - 1, argv + 1, L_HORIZ); |
68 | } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { | 68 | } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { |
69 | swayc_t *focused = current_container; | 69 | swayc_t *focused = current_container; |
70 | if (focused->parent->layout == L_VERT) { | 70 | if (focused->parent->layout == L_VERT) { |
71 | _do_split(argc - 1, argv + 1, L_HORIZ); | 71 | return _do_split(argc - 1, argv + 1, L_HORIZ); |
72 | } else { | 72 | } else { |
73 | _do_split(argc - 1, argv + 1, L_VERT); | 73 | return _do_split(argc - 1, argv + 1, L_VERT); |
74 | } | 74 | } |
75 | } else { | 75 | } else { |
76 | error = cmd_results_new(CMD_FAILURE, "split", | 76 | error = cmd_results_new(CMD_FAILURE, "split", |
77 | "Invalid split command (expected either horizontal or vertical)."); | 77 | "Invalid split command (expected either horizontal or vertical)."); |
78 | return error; | 78 | return error; |
79 | } | 79 | } |
80 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
81 | } | 80 | } |
82 | 81 | ||
83 | struct cmd_results *cmd_splitv(int argc, char **argv) { | 82 | struct cmd_results *cmd_splitv(int argc, char **argv) { |
diff --git a/sway/workspace.c b/sway/workspace.c index 42525f3d..ab27ff56 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -368,6 +368,7 @@ swayc_t *workspace_for_pid(pid_t pid) { | |||
368 | ws = workspace_create(pw->workspace); | 368 | ws = workspace_create(pw->workspace); |
369 | } | 369 | } |
370 | 370 | ||
371 | free_pid_workspace(pw); | ||
371 | list_del(config->pid_workspaces, i); | 372 | list_del(config->pid_workspaces, i); |
372 | } | 373 | } |
373 | 374 | ||