Hello, The analysis and patch look good to me. Gavin, I think that you can apply it (I know that it is a kind of patch practical for git to get both the patch and commiter right, but I don't know how to apply that kind of patch).
On Mon, May 19, 2025 at 06:43:10PM -0700, Collin Funk wrote: > Hi, > > When compiling Texinfo I see the following warning from GCC: > > main/get_perl_info.c: In function 'html_get_button_specification_list': > main/get_perl_info.c:792:28: warning: 'text_type_p' may be used > uninitialized [-Wmaybe-uninitialized] > 792 | if (!strcmp (html_command_text_type_name[j], > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 793 | text_type_p)) > | ~~~~~~~~~~~~ > main/get_perl_info.c:780:25: note: 'text_type_p' was declared here > 780 | char *text_type_p; > | ^~~~~~~~~~~ > > Here is the corresponding section of code: > > int j; > char *text_type_string > = SvPVutf8_nolen (*button_spec_info_type); > char *text_type_p; > if (strlen (text_type_string) > 2 > && !(memcmp (text_type_string, "->", 2))) > { > button_spec->type > = BIT_selected_direction_information_type; > text_type_p = text_type_string +2; > text_type_p += strspn (text_type_p, whitespace_chars); > } > button_spec->bi.direction_information_type = -1; > for (j = 0; j < HTT_section +1; j++) > { > if (!strcmp (html_command_text_type_name[j], > text_type_p)) > { > button_spec->bi.direction_information_type = j; > break; > } > } > > This warning seems accurate to me, since if the first condition is not > satisfied the uninitialized pointer is passed to strcmp. > > I have attached a proposed patch. > > Collin > > From a757289836db44501eb667ee222fa48fd5da31a9 Mon Sep 17 00:00:00 2001 > Message-ID: > <a757289836db44501eb667ee222fa48fd5da31a9.1747705234.git.collin.fu...@gmail.com> > From: Collin Funk <collin.fu...@gmail.com> > Date: Mon, 19 May 2025 18:32:19 -0700 > Subject: [PATCH] Fix an uninitialized variable. > > * tta/C/main/get_perl_info.c (html_get_button_specification_list): > Initialize to text_type_p and then check it before accessing. > --- > tta/C/main/get_perl_info.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/tta/C/main/get_perl_info.c b/tta/C/main/get_perl_info.c > index bf1035dea3..dae1b8600b 100644 > --- a/tta/C/main/get_perl_info.c > +++ b/tta/C/main/get_perl_info.c > @@ -777,7 +777,7 @@ html_get_button_specification_list (const CONVERTER > *converter, > int j; > char *text_type_string > = SvPVutf8_nolen (*button_spec_info_type); > - char *text_type_p; > + char *text_type_p = NULL; > if (strlen (text_type_string) > 2 > && !(memcmp (text_type_string, "->", 2))) > { > @@ -787,15 +787,16 @@ html_get_button_specification_list (const CONVERTER > *converter, > text_type_p += strspn (text_type_p, whitespace_chars); > } > button_spec->bi.direction_information_type = -1; > - for (j = 0; j < HTT_section +1; j++) > - { > - if (!strcmp (html_command_text_type_name[j], > + if (text_type_p) > + for (j = 0; j < HTT_section +1; j++) > + { > + if (!strcmp (html_command_text_type_name[j], > text_type_p)) > - { > - button_spec->bi.direction_information_type = j; > - break; > - } > - } > + { > + button_spec->bi.direction_information_type = j; > + break; > + } > + } > } > } > } > -- > 2.49.0 >