gbranden pushed a commit to branch master
in repository groff.
commit 40fe18446e794be206e52c8d2ddc3af111020cd0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Mar 5 08:36:51 2026 -0600
[troff]: Fix Savannah #67978.
* src/roff/troff/input.cpp (do_device_extension): Emit error diagnostic
instead of accessing invalid memory if an attempt is made to output a
device extension command while the currently selected font is invalid.
In the future we might not need the current font to be valid to format
a device extension node, but for now we do because it "dirties", and
therefore has to subsequently restore, several bits of font-related
state. We might be able to make this unnecessary with a parameterized
extension to the `fl` request. See Savannah #66187.
Fixes <https://savannah.gnu.org/bugs/?67978>.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/input.cpp | 11 +++++++++++
2 files changed, 25 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e7a49375f..93242f997 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-03-10 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (do_device_extension): Emit error
+ diagnostic instead of accessing invalid memory if an attempt is
+ made to output a device extension command while the currently
+ selected font is invalid. In the future we might not need the
+ current font to be valid to format a device extension node, but
+ for now we do because it "dirties", and therefore has to
+ subsequently restore, several bits of font-related state. We
+ might be able to make this unnecessary with a parameterized
+ extension to the `fl` request. See Savannah #66187.
+
+ Fixes <https://savannah.gnu.org/bugs/?67978>.
+
2026-03-09 G. Branden Robinson <[email protected]>
* src/roff/groff/tests/\
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 28d59cd2d..48d727517 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6799,6 +6799,17 @@ static node *do_device_extension() // \X
c = tok.ch();
encode_character_for_device_output(&mac, c);
}
+ // TODO: In the future we might not need the current font to be valid
+ // to format a device extension node, but for now we do because it
+ // "dirties", and therefore has to subsequently restore, several bits
+ // of font-related state. We might be able to make this unnecessary
+ // with a parameterized extension to the `fl` request. See Savannah
+ // #66187.
+ if (!is_valid_font(resolve_current_font_to_mounting_position(curenv)))
+ {
+ error("cannot write device extension command: no current font");
+ return 0 /* nullptr */;
+ }
return new device_extension_node(mac);
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit