gbranden pushed a commit to branch master
in repository groff.

commit 1fcd2248cf1db71055fff25b7d24f9980c763231
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Oct 25 22:26:36 2026 -0500

    [troff]: Fix Savannah #68836.
    
    * src/roff/troff/node.cpp (translate_font_request): Replace assert(3)ion
      that could be tripped by invalid characters in font identifier with
      skip of input line.  Also revise logic to use more early returns,
      simplifying conditional tests.
    
    Fixes <https://savannah.gnu.org/bugs/?68836>.  Problem introduced by me
    in commit ddfc1b7045, 2023-08-27.
---
 ChangeLog               | 10 ++++++++++
 src/roff/troff/node.cpp | 16 ++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 37452fb2f..6a525d82e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-10-25  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (translate_font_request): Replace
+       assert(3)ion that could be tripped by invalid characters in
+       font identifier with skip of input line.  Also revise logic to
+       use more early returns, simplifying conditional tests.
+
+       Fixes <https://savannah.gnu.org/bugs/?68836>.  Problem
+       introduced by me in commit ddfc1b7045, 2023-08-27.
+
 2026-10-25  G. Branden Robinson <[email protected]>
 
        [groff]: Regression-test Savannah #68836.
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 59c88833c..c34275a17 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6825,20 +6825,28 @@ static void translate_font_request() // .ftr
     return;
   }
   symbol from = read_identifier(true /* want_diagnostic */);
-  // has_arg()+read_identifier() should ensure the assertion succeeds.
-  assert(!from.is_null());
+  if (from.is_null()) {
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
   if (is_nonnegative_integer(from.contents())) {
     error("cannot translate a font mounting position");
     skip_line();
     return;
   }
   symbol to = read_identifier();
-  if ((!to.is_null()) && is_nonnegative_integer(to.contents())) {
+  if (to.is_null()) {
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
+  if (is_nonnegative_integer(to.contents())) {
     error("cannot translate to a font mounting position");
     skip_line();
     return;
   }
-  if (to.is_null() || from == to)
+  if (from == to)
     font_translation_dictionary.remove(from);
   else
     (void) font_translation_dictionary.lookup(from,

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

Reply via email to