summaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorlbonn <[email protected]>2019-09-07 23:41:33 +0200
committerDrew DeVault <[email protected]>2019-11-01 12:18:09 -0400
commita6307aed0089a35b5594f910c9604262b46832e6 (patch)
tree4cab6ca6b96b6cabfe224996fc3e8747e4e51272 /sway/commands.c
parent32caabc7a172552a35358d7cde89790ebfa96d48 (diff)
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) {
list_t *execute_command(char *_exec, struct sway_seat *seat,
struct sway_container *con) {
- list_t *res_list = create_list();
- char *exec = strdup(_exec);
- char *head = exec;
char *cmd;
char matched_delim = ';';
list_t *views = NULL;
@@ -213,9 +210,16 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
}
}
+ char *exec = strdup(_exec);
+ char *head = exec;
+ list_t *res_list = create_list();
+
+ if (!res_list || !exec) {
+ return NULL;
+ }
+
config->handler_context.seat = seat;
- head = exec;
do {
for (; isspace(*head); ++head) {}
// Extract criteria (valid for this command list only).