gbranden pushed a commit to branch master
in repository groff.
commit 5787679e7780fd840c03e0ab1911ee804abb1f1a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Nov 20 13:48:45 2025 -0600
[troff]: Add null pointer check.
* src/roff/troff/node.cpp (remove_font_specific_character): Add null
pointer check on `charinfo` object returned by `get_charinfo()` on
token (a character to be removed as a font-specific fallback, which
need not already exist). If null, break from the loop just as is
already done when the lookup on the same character as a font-specific
character takes place. (Font-specific fallback characters are
implemented sneakily by injecting spaces into their identifiers,
making them otherwise invalid. Where `A`, `\[em]` or `\N'45'` are
non-font-specific characters (be they fallbacks or not), `TR \[em]` is
a fallback for `\[em]` specific to the font named `TR`.)
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/input.cpp | 2 +-
src/roff/troff/node.cpp | 4 +++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d3a9cad55..64303feeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-11-20 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp (remove_font_specific_character): Add
+ null pointer check on `charinfo` object returned by
+ `get_charinfo()` on token (a character to be removed as a
+ font-specific fallback, which need not already exist). If null,
+ break from the loop just as is already done when the lookup on
+ the same character as a font-specific character takes place.
+ {Font-specific fallback characters are implemented sneakily by
+ injecting spaces into their identifiers, making them otherwise
+ invalid. Where `A`, `\[em]` or `\N'45'` are non-font-specific
+ characters (be they fallbacks or not), `TR \[em]` is a fallback
+ for `\[em]` specific to the font named `TR`.}
+
2025-11-20 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (print_character_request): Slightly
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 3b8ab5d9e..cac9de35b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6999,7 +6999,7 @@ static bool is_conditional_expression_true()
tok.next();
tok.skip_spaces();
charinfo *ci = tok.get_charinfo(true /* required */);
- if (ci == 0 /* nullptr */) {
+ if (0 == ci /* nullptr */) {
skip_branch();
return false;
}
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 5a7b69183..9e4540d48 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7050,12 +7050,14 @@ 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)
+ break;
string gl(f.contents());
gl += ' ';
gl += s->nm.contents();
gl += '\0';
charinfo *ci = lookup_charinfo(symbol(gl.contents()));
- if (!ci)
+ if (0 /* nullptr */ == ci)
break;
macro *m = ci->set_macro(0 /* nullptr */);
if (m != 0 /* nullptr */)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit