Update of bug #68819 (group groff):
Status: Confirmed => In Progress
Planned Release: None => 1.25.0
Summary: [troff] assertion failure when `chop` request given
invalid identifier => [PATCH] [troff] assertion failure when `chop` request
given invalid identifier
_______________________________________________________
Follow-up Comment #1:
commit e7536611bcb0ecafbb801995588ae2bdbd5dee9c
Author: G. Branden Robinson <[email protected]>
Date: Thu Oct 22 11:18:57 2026 -0500
[groff]: Regression-test Savannah #68819.
* src/roff/groff/tests/error-chop-request-given-bogus-argument.sh: New
file; do it.
* src/roff/groff/groff.am: Update `groff_TESTS` to run test.
Test fails at this commit.
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 4ca89b631..49fe0f835 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -104,6 +104,7 @@ groff_TESTS = \
src/roff/groff/tests/dt-request-works.sh \
src/roff/groff/tests/dvi-device-smoke-test.sh \
src/roff/groff/tests/error-als-request-given-bogus-arguments.sh \
+ src/roff/groff/tests/error-chop-request-given-bogus-argument.sh \
src/roff/groff/tests/error-close-request-given-empty-argument.sh \
src/roff/groff/tests/error-defcolor-request-given-bogus-arguments.sh \
src/roff/groff/tests/error-dt-request-given-bogus-arguments.sh \
diff --git a/src/roff/groff/tests/error-chop-request-given-bogus-argument.sh
b/src/roff/groff/tests/error-chop-request-given-bogus-argument.sh
new file mode 100755
index 000000000..ea3973380
--- /dev/null
+++ b/src/roff/groff/tests/error-chop-request-given-bogus-argument.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+# Regression-test Savannah #68819.
+
+output=$(printf '.chop \002\n' | "$groff" -T ascii)
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
commit 129dbf2bd5841a49c74cbfb3b4a143a82ac1386a
Author: G. Branden Robinson <[email protected]>
Date: 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.
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();
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68819>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
