[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #66079] [troff] uninitialized local `s` potentially used in `token:
From: |
G. Branden Robinson |
Subject: |
[bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()` |
Date: |
Wed, 21 Aug 2024 08:35:18 -0400 (EDT) |
Follow-up Comment #6, bug #66079 (group groff):
Hi Lukas,
In your second patch, there is no use of an uninitialized value; nothing ever
dereferences `s`. This is true even though it is later written to.
However, the variable needs to exist because the API demands a dead store
here, so I'm changing the function to significantly narrow the scope of this
all-but-unused local variable.
Here's the patched function:
297 void environment::add_char(charinfo *ci)
298 {
299 node *gc_np = 0 /* nullptr */;
300 if (line_interrupted)
301 ;
302 // don't allow fields in dummy environments
303 else if (ci == field_delimiter_char && !dummy) {
304 if (has_current_field)
305 wrap_up_field();
306 else
307 start_field();
308 }
309 else if (has_current_field && ci == padding_indicator_char)
310 add_padding();
311 else if (current_tab != TAB_NONE) {
312 if (tab_contents == 0 /* nullptr */)
313 tab_contents = new line_start_node;
314 if (ci != hyphen_indicator_char) {
315 int s;
316 tab_contents = tab_contents->add_char(ci, this, &tab_width, &s,
317 &gc_np);
318 }
319 else
320 tab_contents = tab_contents->add_discretionary_hyphen();
321 }
322 else {
323 if (line == 0 /* nullptr */)
324 start_line();
325 #if 0
326 fprintf(stderr, "current line is\n");
327 line->dump_node_list();
328 #endif
329 if (ci != hyphen_indicator_char)
330 line = line->add_char(ci, this, &width_total, &space_total,
&gc_np);
331 else
332 line = line->add_discretionary_hyphen();
333 }
334 #if 0
335 fprintf(stderr, "now after we have added character the line is\n");
336 line->dump_node_list();
337 #endif
338 if ((!suppress_push) && gc_np) {
339 if (gc_np && (gc_np->state == 0 /* nullptr */)) {
340 gc_np->state = construct_state(false);
341 gc_np->push_state = get_diversion_state();
342 }
343 else if (line && (line->state == 0 /* nullptr */)) {
344 line->state = construct_state(false);
345 line->push_state = get_diversion_state();
346 }
347 }
348 #if 0
349 fprintf(stderr, "now we have possibly added the state the line
is\n");
350 line->dump_node_list();
351 #endif
352 }
...and the patch itself.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index c3990f040..fa86b0504 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -296,7 +296,6 @@ void leader_character()
void environment::add_char(charinfo *ci)
{
- int s;
node *gc_np = 0 /* nullptr */;
if (line_interrupted)
;
@@ -312,8 +311,11 @@ void environment::add_char(charinfo *ci)
else if (current_tab != TAB_NONE) {
if (tab_contents == 0 /* nullptr */)
tab_contents = new line_start_node;
- if (ci != hyphen_indicator_char)
- tab_contents = tab_contents->add_char(ci, this, &tab_width, &s,
&gc_np);
+ if (ci != hyphen_indicator_char) {
+ int s;
+ tab_contents = tab_contents->add_char(ci, this, &tab_width, &s,
+ &gc_np);
+ }
else
tab_contents = tab_contents->add_discretionary_hyphen();
}
Thanks for the report.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66079>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
- [bug #66079] [troff] Uninitialized variable used within add_char function in roff/troff/input.cpp, Lukas Javorsky, 2024/08/12
- [bug #66079] [troff] Uninitialized variable used within add_char function in roff/troff/input.cpp, Lukas Javorsky, 2024/08/13
- [bug #66079] [troff] Uninitialized variable used within add_char function in roff/troff/input.cpp, Lukas Javorsky, 2024/08/13
- [bug #66079] [troff] uninitialized local `s` used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/14
- [bug #66079] [troff] uninitialized local `s` used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/14
- [bug #66079] [troff] uninitialized local `s` used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/14
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/14
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/15
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`, Lukas Javorsky, 2024/08/21
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/21
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`,
G. Branden Robinson <=
- [bug #66079] [troff] uninitialized local `s` potentially used in `token::add_to_zero_width_node_list()`, G. Branden Robinson, 2024/08/21