aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/assign.c1
-rw-r--r--sway/commands/bar/font.c2
-rw-r--r--sway/commands/bar/modifier.c5
-rw-r--r--sway/commands/input/accel_profile.c1
-rw-r--r--sway/commands/input/click_method.c1
-rw-r--r--sway/commands/input/drag_lock.c1
-rw-r--r--sway/commands/input/dwt.c1
-rw-r--r--sway/commands/input/events.c1
-rw-r--r--sway/commands/input/left_handed.c1
-rw-r--r--sway/commands/input/map_from_region.c8
-rw-r--r--sway/commands/input/middle_emulation.c1
-rw-r--r--sway/commands/input/natural_scroll.c1
-rw-r--r--sway/commands/input/pointer_accel.c1
-rw-r--r--sway/commands/input/repeat_delay.c1
-rw-r--r--sway/commands/input/repeat_rate.c1
-rw-r--r--sway/commands/input/scroll_method.c1
-rw-r--r--sway/commands/input/tap.c1
-rw-r--r--sway/commands/output/background.c3
-rw-r--r--sway/commands/output/mode.c2
-rw-r--r--sway/commands/output/position.c2
20 files changed, 30 insertions, 6 deletions
diff --git a/sway/commands/assign.c b/sway/commands/assign.c
index 9d15e166..a90498ce 100644
--- a/sway/commands/assign.c
+++ b/sway/commands/assign.c
@@ -27,6 +27,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
if (strncmp(*argv, "→", strlen("→")) == 0) {
if (argc < 3) {
+ free(criteria);
return cmd_results_new(CMD_INVALID, "assign", "Missing workspace");
}
++argv;
diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c
index 80b7a593..f036cbc3 100644
--- a/sway/commands/bar/font.c
+++ b/sway/commands/bar/font.c
@@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) {
}
char *font = join_args(argv, argc);
free(config->current_bar->font);
- config->current_bar->font = strdup(font);
+ config->current_bar->font = font;
wlr_log(L_DEBUG, "Settings font '%s' for bar: %s",
config->current_bar->font, config->current_bar->id);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c
index 7ba4b125..02f845e6 100644
--- a/sway/commands/bar/modifier.c
+++ b/sway/commands/bar/modifier.c
@@ -22,9 +22,10 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
mod |= tmp_mod;
continue;
} else {
+ error = cmd_results_new(CMD_INVALID, "modifier",
+ "Unknown modifier '%s'", split->items[i]);
free_flat_list(split);
- return cmd_results_new(CMD_INVALID, "modifier",
- "Unknown modifier '%s'", split->items[i]);
+ return error;
}
}
free_flat_list(split);
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index 37d6e133..a4108ec3 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -23,6 +23,7 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
} else if (strcasecmp(argv[0], "flat") == 0) {
new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "accel_profile",
"Expected 'accel_profile <adaptive|flat>'");
}
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 8f1f0aa7..5d0d8cc2 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -26,6 +26,7 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "clickfinger") == 0) {
new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "click_method",
"Expected 'click_method <none|button_areas|clickfinger'");
}
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index 8273a7d4..9e32816f 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -23,6 +23,7 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "drag_lock",
"Expected 'drag_lock <enabled|disabled>'");
}
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index 995a2f47..73937507 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -22,6 +22,7 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "dwt",
"Expected 'dwt <enabled|disabled>'");
}
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 2217f5ce..e2ccdc94 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -29,6 +29,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
new_config->send_events =
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "events",
"Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
}
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 94b8e03e..769ce98c 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -23,6 +23,7 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->left_handed = 0;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "left_handed",
"Expected 'left_handed <enabled|disabled>'");
}
diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c
index 80bb856d..40f04214 100644
--- a/sway/commands/input/map_from_region.c
+++ b/sway/commands/input/map_from_region.c
@@ -54,20 +54,28 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
bool mm1, mm2;
if (!parse_coords(argv[0], &new_config->mapped_from_region->x1,
&new_config->mapped_from_region->y1, &mm1)) {
+ free(new_config->mapped_from_region);
+ free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid top-left coordinates");
}
if (!parse_coords(argv[1], &new_config->mapped_from_region->x2,
&new_config->mapped_from_region->y2, &mm2)) {
+ free(new_config->mapped_from_region);
+ free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid bottom-right coordinates");
}
if (new_config->mapped_from_region->x1 > new_config->mapped_from_region->x2 ||
new_config->mapped_from_region->y1 > new_config->mapped_from_region->y2) {
+ free(new_config->mapped_from_region);
+ free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid rectangle");
}
if (mm1 != mm2) {
+ free(new_config->mapped_from_region);
+ free_input_config(new_config);
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Both coordinates must be in the same unit");
}
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index a551fd51..7ca01629 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -24,6 +24,7 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
new_config->middle_emulation =
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "middle_emulation",
"Expected 'middle_emulation <enabled|disabled>'");
}
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index c4e19b78..55236790 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -23,6 +23,7 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->natural_scroll = 0;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "natural_scroll",
"Expected 'natural_scroll <enabled|disabled>'");
}
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index 171063aa..8bbd0724 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -20,6 +20,7 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
float pointer_accel = atof(argv[0]);
if (pointer_accel < -1 || pointer_accel > 1) {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "pointer_accel",
"Input out of range [-1, 1]");
}
diff --git a/sway/commands/input/repeat_delay.c b/sway/commands/input/repeat_delay.c
index ce265841..c9ddbf0e 100644
--- a/sway/commands/input/repeat_delay.c
+++ b/sway/commands/input/repeat_delay.c
@@ -20,6 +20,7 @@ struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
int repeat_delay = atoi(argv[0]);
if (repeat_delay < 0) {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "repeat_delay",
"Repeat delay cannot be negative");
}
diff --git a/sway/commands/input/repeat_rate.c b/sway/commands/input/repeat_rate.c
index f2ea2e69..56878176 100644
--- a/sway/commands/input/repeat_rate.c
+++ b/sway/commands/input/repeat_rate.c
@@ -20,6 +20,7 @@ struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
int repeat_rate = atoi(argv[0]);
if (repeat_rate < 0) {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "repeat_rate",
"Repeat rate cannot be negative");
}
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index 0a1c57ac..4c6ac6b6 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -27,6 +27,7 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "on_button_down") == 0) {
new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "scroll_method",
"Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
}
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index e7f03058..7d027d5d 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -23,6 +23,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
} else if (strcasecmp(argv[0], "disabled") == 0) {
new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
} else {
+ free_input_config(new_config);
return cmd_results_new(CMD_INVALID, "tap",
"Expected 'tap <enabled|disabled>'");
}
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 55cbdff0..65b5f902 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -81,8 +81,9 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
// src file is inside configuration dir
char *conf = strdup(config->current_config);
- if(!conf) {
+ if (!conf) {
wlr_log(L_ERROR, "Failed to duplicate string");
+ free(src);
return cmd_results_new(CMD_FAILURE, "output",
"Unable to allocate resources");
}
diff --git a/sway/commands/output/mode.c b/sway/commands/output/mode.c
index daec6d44..ef56ae9e 100644
--- a/sway/commands/output/mode.c
+++ b/sway/commands/output/mode.c
@@ -36,11 +36,11 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
}
} else {
// Format is 1234 4321
+ argc--; argv++;
if (!argc) {
return cmd_results_new(CMD_INVALID, "output",
"Missing mode argument (height).");
}
- argc--; argv++;
output->height = strtol(*argv, &end, 10);
if (*end) {
return cmd_results_new(CMD_INVALID, "output",
diff --git a/sway/commands/output/position.c b/sway/commands/output/position.c
index c2aeb281..449767b1 100644
--- a/sway/commands/output/position.c
+++ b/sway/commands/output/position.c
@@ -27,11 +27,11 @@ struct cmd_results *output_cmd_position(int argc, char **argv) {
}
} else {
// Format is 1234 4321 (legacy)
+ argc--; argv++;
if (!argc) {
return cmd_results_new(CMD_INVALID, "output",
"Missing position argument (y).");
}
- argc--; argv++;
config->handler_context.output_config->y = strtol(*argv, &end, 10);
if (*end) {
return cmd_results_new(CMD_INVALID, "output",