gbranden pushed a commit to branch master
in repository groff.

commit 158b0d973e6e802558b7a4611fc56c52bd8864e9
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 24 00:28:57 2025 -0600

    [troff]: Soften some assertions to errors.
    
    * src/roff/troff/input.cpp (do_overstrike, do_bracket, token::next):
      Convert some recent assertions to error diagnostics, since inputs to
      provoke them are not impossible.  I found these by attempting to
      format GNU troff's own ELF executable as a document (the laziest
      possible fuzz testing).
---
 ChangeLog                |  8 ++++++++
 src/roff/troff/input.cpp | 16 ++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 856506190..f24194c9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-11-24  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (do_overstrike, do_bracket)
+       (token::next): Convert some recent assertions to error
+       diagnostics, since inputs to provoke them are not impossible.
+       I found these by attempting to format GNU troff's own ELF
+       executable as a document (the laziest possible fuzz testing).
+
 2025-11-23  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (token::description): Add description
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 937355192..40ad5715e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1671,10 +1671,11 @@ node *do_overstrike() // \o
       osnode->overstrike(n);
     }
     else {
+      // TODO: In theory, we could accept spaces and horizontal motions.
       charinfo *ci = tok.get_charinfo(true /* required */);
       if (0 /* nullptr */ == ci) {
-       assert(0 == "attempted to use token without charinfo in"
-              " overstrike escape sequence");
+       error("%1 is not supported in an overstrike escape sequence"
+             " argument", tok.description());
        delete osnode;
        return 0 /* nullptr */;
       }
@@ -1729,10 +1730,11 @@ static node *do_bracket() // \b
     if (tok == start_token
        && (want_att_compat || input_stack::get_level() == start_level))
       break;
+    // TODO: In theory, we could accept spaces and horizontal motions.
     charinfo *ci = tok.get_charinfo(true /* required */);
     if (0 /* nullptr */ == ci) {
-      assert(0 == "attempted to use token without charinfo in"
-            " bracket-building escape sequence");
+      error("%1 is not supported in a bracket-building escape sequence"
+           " argument", tok.description());
       delete bracketnode;
       return 0 /* nullptr */;
     }
@@ -2651,10 +2653,12 @@ void token::next()
          if (type == TOKEN_NODE || type == TOKEN_HORIZONTAL_SPACE)
            nd = new zero_width_node(nd);
          else {
+           // TODO: In theory, we could accept spaces and horizontal
+           // motions.
            charinfo *ci = get_charinfo(true /* required */);
            if (0 /* nullptr */ == ci) {
-             assert(0 == "attempted to use token without charinfo in"
-                    " zero-width escape sequence");
+             error("%1 is not supported in a zero-width character"
+                   " escape sequence argument", tok.description());
              break;
            }
            node *gn = curenv->make_char_node(ci);

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to