aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorMikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-11-28 22:02:06 +0100
committerMikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-11-28 22:02:06 +0100
commitc477bbf345ccfcc5b48bb49c9f9784e8d8a7bfac (patch)
tree1f5a3be278c9bfd489d4b96b652d1ff2d1a7cb99 /sway/commands.c
parent01617131f110a3a80987706ff6e86c46f2269255 (diff)
Add warnings about invalid output commands
This handles some cases where sway will crash if an output command is invalid/missing an argument.
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c
index a46a0b89..42845f65 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -767,8 +767,14 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
output->y = y;
} else if (strcasecmp(argv[i], "bg") == 0 || strcasecmp(argv[i], "background") == 0) {
wordexp_t p;
- char *src = argv[++i];
- char *mode = argv[++i];
+ if (++i >= argc) {
+ return cmd_results_new(CMD_INVALID, "output", "Missing background file.");
+ }
+ char *src = argv[i];
+ if (++i >= argc) {
+ return cmd_results_new(CMD_INVALID, "output", "Missing background scaling mode.");
+ }
+ char *mode = argv[i];
if (wordexp(src, &p, 0) != 0) {
return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src);
}