gbranden pushed a commit to branch master
in repository groff.

commit 9f0536f8f5383c227f7fc7d4f5eab34f14526627
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Oct 22 11:27:14 2026 -0500

    [troff]: Fix Savannah #68819.
    
    * src/roff/troff/input.cpp (chop_request): Replace assert(3)ion that
      could be tripped by invalid characters in macro/string/
      request/diversion identifier with skip of input line.
    
    Fixes <https://savannah.gnu.org/bugs/?68819>.  Problem introduced by me
    in commit 12cb5ec593, 2024-09-20.
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/input.cpp | 28 +++++++++++++++-------------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 51d21bad3..ead54264b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-10-22  G. Branden Robinson <[email protected]>
+
+       [troff]: Fix Savannah #68819.
+
+       * src/roff/troff/input.cpp (chop_request): Replace assert(3)ion
+       that could be tripped by invalid characters in macro/string/
+       request/diversion identifier with skip of input line.
+
+       Fixes <https://savannah.gnu.org/bugs/?68819>.  Problem
+       introduced by me in commit 12cb5ec593, 2024-09-20.
+
 2026-10-22  G. Branden Robinson <[email protected]>
 
        [groff]: Regression-test Savannah #68819.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index dc05f131c..75940d503 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5917,20 +5917,22 @@ static void chop_request() // .chop
     return;
   }
   symbol s = read_identifier();
-  assert(s != 0 /* nullptr */);
-  if (!s.is_null()) {
-    request_or_macro *p = lookup_request(s);
-    macro *m = p->to_macro();
-    if (0 /* nullptr */ == m)
-      error("cannot chop request '%1'", s.contents());
-    // TODO: If it's empty, do nothing, quietly?
-    else if (m->is_empty())
-      error("cannot chop empty %1 '%2'",
-           (m->is_diversion() ? "diversion" : "macro or string"),
-           s.contents());
-    else
-      m->chop();
+  if (s.is_null()) {
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
   }
+  request_or_macro *p = lookup_request(s);
+  macro *m = p->to_macro();
+  if (0 /* nullptr */ == m)
+    error("cannot chop request '%1'", s.contents());
+  // TODO: If it's empty, do nothing, quietly?
+  else if (m->is_empty())
+    error("cannot chop empty %1 '%2'",
+         (m->is_diversion() ? "diversion" : "macro or string"),
+         s.contents());
+  else
+    m->chop();
   skip_line();
 }
 

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

Reply via email to