Fix segfault for wayvncctl help --command=bad-name

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
pull/216/head
Jim Ramsay 2023-01-02 20:15:12 -05:00
parent 522b1deb28
commit d475e0e52f
1 changed files with 4 additions and 0 deletions

View File

@ -650,6 +650,10 @@ static int print_command_usage(const char* cmd_name,
struct option_parser* parent_options) struct option_parser* parent_options)
{ {
struct cmd_info* info = ctl_command_by_name(cmd_name); struct cmd_info* info = ctl_command_by_name(cmd_name);
if (!info) {
WARN("No such command \"%s\"\n", cmd_name);
return 1;
}
printf("Usage: wayvncctl [options] %s [parameters]\n\n%s\n\n", cmd_name, printf("Usage: wayvncctl [options] %s [parameters]\n\n%s\n\n", cmd_name,
info->description); info->description);
option_parser_print_options(cmd_options, stdout); option_parser_print_options(cmd_options, stdout);