ctl-server: Fix segfault in error path

This would segfault e.g. if issuing:
$ waynvcctl client-disconnect # without argument
srht-ci
Andri Yngvason 2023-01-15 17:49:33 +00:00
parent 6e326af2ff
commit 0b970ba355
1 changed files with 3 additions and 3 deletions

View File

@ -202,7 +202,6 @@ static struct cmd* parse_command(struct jsonipc_request* ipc,
case CMD_OUTPUT_LIST: case CMD_OUTPUT_LIST:
case CMD_OUTPUT_CYCLE: case CMD_OUTPUT_CYCLE:
case CMD_WAYVNC_EXIT: case CMD_WAYVNC_EXIT:
cmd = calloc(1, sizeof(*cmd));
break; break;
case CMD_UNKNOWN: case CMD_UNKNOWN:
jsonipc_error_set_new(err, ENOENT, jsonipc_error_set_new(err, ENOENT,
@ -211,9 +210,10 @@ static struct cmd* parse_command(struct jsonipc_request* ipc,
jprintf("Unknown command \"%s\"", jprintf("Unknown command \"%s\"",
ipc->method), ipc->method),
"commands", list_allowed_commands())); "commands", list_allowed_commands()));
return NULL; break;
} }
cmd->type = cmd_type; if (cmd)
cmd->type = cmd_type;
return cmd; return cmd;
} }