]> git.draconx.ca Git - cdecl99.git/commitdiff
cdecl99: Avoid passing uninitialized value to help_print_option.
authorNick Bowler <nbowler@draconx.ca>
Fri, 16 Jun 2023 04:34:41 +0000 (00:34 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 16 Jun 2023 04:34:41 +0000 (00:34 -0400)
For options that do not take arguments, the "arg" member of the help
structure is not assigned by lopt_get_help.  Since the structure
is not otherwise initialized, it is technically undefined to even
evaluate this member in order to pass it to the help_print_option
function.

In this case, the argument is not actually used, and I'm not aware
of any actual failures as a result, but it easy enough to avoid.

src/cdecl99.c

index eac0023731ce9838342dd286032ad876c36463b4..5ddc889f05168d279d32eb88612231a848f1a8f3 100644 (file)
@@ -79,6 +79,7 @@ static void print_usage(FILE *f)
 
 static void print_help(const struct option *lopts)
 {
+       struct lopt_help help = {0};
        const struct option *opt;
 
        print_usage(stdout);
@@ -89,8 +90,6 @@ static void print_help(const struct option *lopts)
 
        puts(_("Options:"));
        for (opt = lopts; opt->name; opt++) {
-               struct lopt_help help;
-
                if (!lopt_get_help(opt, &help))
                        continue;