aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sway/commands.c12
-rw-r--r--sway/config.c2
-rw-r--r--sway/main.c1
3 files changed, 11 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).
diff --git a/sway/config.c b/sway/config.c
index bb5b920b..afc60a42 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -687,8 +687,10 @@ static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file,
nread += next_nread - 2;
if ((ssize_t) *line_size < nread + 1) {
*line_size = nread + 1;
+ char *old_ptr = *lineptr;
*lineptr = realloc(*lineptr, *line_size);
if (!*lineptr) {
+ free(old_ptr);
nread = -1;
break;
}
diff --git a/sway/main.c b/sway/main.c
index 177c0aa1..2cc69dfb 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -259,6 +259,7 @@ int main(int argc, char **argv) {
exit(EXIT_SUCCESS);
break;
case 'c': // config
+ free(config_path);
config_path = strdup(optarg);
break;
case 'C': // validate