From e3837ba634dd51482bb89cfa2b2f13f01bfcbcb6 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Mon, 19 Oct 2015 19:42:49 +0200 Subject: [PATCH] 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)`. --- sway/commands.c | 5 +++++ 1 file changed, 5 insertions(+) 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;