check for workspace command name arg (fix #5131)

For the 'workspace <name> output <output>' command, output_location must
be greater than zero or the attempt to get the workspace name with
join_args will segfault or abort() (depending on the flavor of
sway_assert() in use). This checks and returns an error instead.
This commit is contained in:
Ryan Farley 2020-03-23 18:48:44 -05:00
parent 0b9feb6f39
commit 239e658f6b

View file

@ -140,7 +140,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
break; break;
} }
} }
if (output_location >= 0) { if (output_location == 0) {
return cmd_results_new(CMD_INVALID, "Expected 'workspace "
"<name> output <output>'");
} else if (output_location > 0) {
if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST,
output_location + 2))) { output_location + 2))) {
return error; return error;