aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorS. Christoffer Eliesen <christoffer@eliesen.no>2015-10-19 19:42:49 +0200
committerS. Christoffer Eliesen <christoffer@eliesen.no>2015-10-19 19:45:35 +0200
commite3837ba634dd51482bb89cfa2b2f13f01bfcbcb6 (patch)
tree223b4bf653a5a77b3940c28b541048c6029f4886 /sway/commands.c
parent83c23f274c89e31473fd13b93f287e1c7516a040 (diff)
commands: Gracefully handle empty commands.
Before this patch sway would proceed into find_handler which would cause a crash trying to parse a NULL string. This could be triggered via e.g. `i3-msg -s $(sway --get-socketpath)`.
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 5afddc4a..eb77c172 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1178,6 +1178,11 @@ enum cmd_status handle_command(char *_exec) {
// Split commands
cmd = argsep(&cmdlist, ",");
cmd += strspn(cmd, whitespace);
+ if (strcmp(cmd, "") == 0) {
+ sway_log(L_INFO, "Ignoring empty command.");
+ continue;
+ }
+
sway_log(L_INFO, "Handling command '%s'", cmd);
//TODO better handling of argv
int argc;