gbranden pushed a commit to branch master
in repository groff.
commit f42d6c6d2f586ec5c66f4a1dbc5b989e0a7dfc84
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 21 22:13:04 2025 -0600
[troff]: Recover from invalid `rfschar` req.
* src/roff/troff/node.cpp (remove_font_specific_character): Recover from
invalid input more robustly. If we encounter an invalid character
token in the `rfschar` argument list (one that has a null pointer to
its `charinfo`), and the build used `NDEBUG` to suppress assertions,
skip the character and process the next token (if any) instead of
ignoring the rest of the input line, as the `cflags` and `rchar`
requests do.
---
ChangeLog | 10 ++++++++++
src/roff/troff/node.cpp | 24 ++++++++++++------------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a8b6ce370..6b08374d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-11-21 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp (remove_font_specific_character):
+ Recover from invalid input more robustly. If we encounter an
+ invalid character token in the `rfschar` argument list (one that
+ has a null pointer to its `charinfo`), and the build used
+ `NDEBUG` to suppress assertions, skip the character and process
+ the next token (if any) instead of ignoring the rest of the
+ input line, as the `cflags` and `rchar` requests do.
+
2025-11-19 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (define_character, get_line_arg)
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 6d2d22a91..6775d7a2d 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7050,21 +7050,21 @@ static void remove_font_specific_character()
while (!tok.is_newline() && !tok.is_eof()) {
if (!tok.is_space() && !tok.is_tab()) {
charinfo *s = tok.get_charinfo(true /* required */);
- if (0 /* nullptr */ == s) {
+ if (0 /* nullptr */ == s)
assert(0 == "attempted to use token without charinfo in"
" font-specific character removal request");
- break;
+ else {
+ string gl(f.contents());
+ gl += ' ';
+ gl += s->nm.contents();
+ gl += '\0';
+ charinfo *ci = lookup_charinfo(symbol(gl.contents()));
+ if (0 /* nullptr */ == ci)
+ break;
+ macro *m = ci->set_macro(0 /* nullptr */);
+ if (m != 0 /* nullptr */)
+ delete m;
}
- string gl(f.contents());
- gl += ' ';
- gl += s->nm.contents();
- gl += '\0';
- charinfo *ci = lookup_charinfo(symbol(gl.contents()));
- if (0 /* nullptr */ == ci)
- break;
- macro *m = ci->set_macro(0 /* nullptr */);
- if (m != 0 /* nullptr */)
- delete m;
}
tok.next();
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit