Skip to content

Commit

Permalink
don't segfault when asked for help
Browse files Browse the repository at this point in the history
print the help for the current command if there are no subcommands
to list
  • Loading branch information
mcnewton committed Sep 17, 2015
1 parent 6fd5c52 commit a3bb4f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/command.c
Expand Up @@ -2851,10 +2851,19 @@ static void print_help(rad_listen_t *listener, int argc, char *argv[],
{
int i;

/* this should never happen, but if it does then just return gracefully */
if (!table) return;

for (i = 0; table[i].command != NULL; i++) {
if (argc > 0) {
if (strcmp(table[i].command, argv[0]) == 0) {
print_help(listener, argc - 1, argv + 1, table[i].table, recursive);
if (table[i].table) {
print_help(listener, argc - 1, argv + 1, table[i].table, recursive);
} else {
if (table[i].help) {
cprintf(listener, "%s\n", table[i].help);
}
}
return;
}

Expand Down

0 comments on commit a3bb4f4

Please sign in to comment.