From a3bb4f4c9c04e60d388264256fd72f5fafc039c9 Mon Sep 17 00:00:00 2001 From: Matthew Newton Date: Fri, 18 Sep 2015 00:36:41 +0100 Subject: [PATCH] don't segfault when asked for help print the help for the current command if there are no subcommands to list --- src/main/command.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/command.c b/src/main/command.c index 99fa117d950..099bb782596 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -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; } -- 2.47.3