aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
authorLibravatar lbonn <bonnans.l@gmail.com>2019-09-07 23:41:33 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-11-01 12:18:09 -0400
commita6307aed0089a35b5594f910c9604262b46832e6 (patch)
tree4cab6ca6b96b6cabfe224996fc3e8747e4e51272 /sway/commands.c
parentseat: simplify a strdup (diff)
downloadsway-a6307aed0089a35b5594f910c9604262b46832e6.tar.gz
sway-a6307aed0089a35b5594f910c9604262b46832e6.tar.zst
sway-a6307aed0089a35b5594f910c9604262b46832e6.zip
Fix various memory leaks
Found with clang-tidy
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 2c1b2cb9..e2c43e9f 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -198,9 +198,6 @@ static void set_config_node(struct sway_node *node) {
198 198
199list_t *execute_command(char *_exec, struct sway_seat *seat, 199list_t *execute_command(char *_exec, struct sway_seat *seat,
200 struct sway_container *con) { 200 struct sway_container *con) {
201 list_t *res_list = create_list();
202 char *exec = strdup(_exec);
203 char *head = exec;
204 char *cmd; 201 char *cmd;
205 char matched_delim = ';'; 202 char matched_delim = ';';
206 list_t *views = NULL; 203 list_t *views = NULL;
@@ -213,9 +210,16 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
213 } 210 }
214 } 211 }
215 212
213 char *exec = strdup(_exec);
214 char *head = exec;
215 list_t *res_list = create_list();
216
217 if (!res_list || !exec) {
218 return NULL;
219 }
220
216 config->handler_context.seat = seat; 221 config->handler_context.seat = seat;
217 222
218 head = exec;
219 do { 223 do {
220 for (; isspace(*head); ++head) {} 224 for (; isspace(*head); ++head) {}
221 // Extract criteria (valid for this command list only). 225 // Extract criteria (valid for this command list only).