Fix segfault in openssl app called with no args.
[openssl.git] / apps / openssl.c
index 7b0ccbcc092ee1cf70ede9af5788f6a30f4b3628..4c97936824ca556138ee25fbd0d64999c913b5ec 100644 (file)
@@ -308,6 +308,13 @@ int help_main(int argc, char **argv)
     char *prog;
     HELP_CHOICE o;
     DISPLAY_COLUMNS dc;
+    char *new_argv[3];
+
+    if (argc == 0) {
+        new_argv[0] = "help";
+        new_argv[1] = NULL;
+        return do_cmd(prog_init(), 1, new_argv);
+    }
 
     prog = opt_init(argc, argv, help_options);
     while ((o = opt_next()) != OPT_hEOF) {
@@ -323,8 +330,6 @@ int help_main(int argc, char **argv)
     }
 
     if (opt_num_rest() == 1) {
-        char *new_argv[3];
-
         new_argv[0] = opt_rest()[0];
         new_argv[1] = "--help";
         new_argv[2] = NULL;