gbranden pushed a commit to branch master
in repository groff.
commit 1e25f043ec0634acd902ef07543cebd2034d869a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 4 17:07:49 2026 -0500
[troff]: Add assertion and null pointer check.
* src/roff/troff/input.cpp (process_input_stack): Add null pointer check
when processing a horizontal motion token. An experimental code
change in my working copy while exploring Savannah #68303 caused a
SEGV in a place I didn't expect. While that change is likely
erroneous, it appears to have revealed an implicit invariant. Make
the invariant explicit, as above, and add an assert(3)ion for it as
well.
---
ChangeLog | 10 ++++++++++
src/roff/troff/input.cpp | 8 +++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 84a3a072a..333ace89e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-05-04 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (process_input_stack): Add null
+ pointer check when processing a horizontal motion token. An
+ experimental code change in my working copy while exploring
+ Savannah #68303 caused a SEGV in a place I didn't expect. While
+ that change is likely erroneous, it appears to have revealed an
+ implicit invariant. Make the invariant explicit, as above, and
+ add an assert(3)ion for it as well.
+
2026-04-29 Dave Kemper <[email protected]>
* doc/groff.texi.in (Ligatures and Kerning):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 3e4d99328..51e344364 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3775,6 +3775,7 @@ void process_input_stack()
case token::TOKEN_NODE:
case token::TOKEN_DELIMITED_HORIZONTAL_MOTION:
case token::TOKEN_HORIZONTAL_MOTION:
+ assert(tok.nd != 0 /* nullptr */);
if (curenv->get_was_line_interrupted()) {
// We don't want to warn about node types. They might have been
// interpolated into the input by the formatter itself, as with
@@ -3787,13 +3788,14 @@ void process_input_stack()
}
else if (possibly_handle_first_page_transition())
;
- else if (tok.nd->need_reread(&can_accept_control_character)) {
+ else if (tok.nd != 0 /* nullptr */
+ && tok.nd->need_reread(&can_accept_control_character)) {
delete tok.nd;
- tok.nd = 0;
+ tok.nd = 0 /* nullptr */;
}
else {
curenv->add_node(tok.nd);
- tok.nd = 0;
+ tok.nd = 0 /* nullptr */;
can_accept_control_character = false;
curenv->possibly_break_line(true /* must break here */);
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit