Merge pull request #1246 from mcnewton/v3.0.x
authorAlan DeKok <aland@freeradius.org>
Fri, 18 Sep 2015 11:37:59 +0000 (07:37 -0400)
committerAlan DeKok <aland@freeradius.org>
Fri, 18 Sep 2015 11:37:59 +0000 (07:37 -0400)
don't segfault when asked for help

src/main/command.c

index 99fa117..099bb78 100644 (file)
@@ -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;
                        }