gbranden pushed a commit to branch master
in repository groff.

commit 9d716dd91e43033e5a8cbeb370c4845130815f06
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 1 23:22:18 2026 -0600

    [troff]: Warn on negative `ne` and `sv` arguments.
    
    * src/roff/troff/div.cpp (need_vertical_space_request)
      (save_vertical_space_request): Throw warning in category "range" and
      ignore request if a negative argument is specified.
    
    Fixes <https://savannah.gnu.org/bugs/?68871>.
---
 ChangeLog              |  8 ++++++++
 src/roff/troff/div.cpp | 12 ++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 26778f284..4cc5bf38b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-11-01  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/div.cpp (need_vertical_space_request)
+       (save_vertical_space_request): Throw warning in category "range"
+       and ignore request if a negative argument is specified.
+
+       Fixes <https://savannah.gnu.org/bugs/?68871>.
+
 2026-10-31  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp (translate_font_request): Distinguish
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 9fafa7235..eb0b02e84 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -922,6 +922,12 @@ static void need_vertical_space_request() // .ne
   vunits n;
   if (!has_arg() || !read_vunits(&n, 'v'))
     n = curenv->get_vertical_spacing();
+  if (n < V0) {
+    warning(WARN_RANGE, "ignoring request to require negative amount"
+                       " of vertical space: %1u", n.to_units());
+    skip_line();
+    return;
+  }
   while (!tok.is_terminator())
     tok.next();
   curdiv->need(n);
@@ -949,6 +955,12 @@ static void save_vertical_space_request() // .sv
   vunits x;
   if (!has_arg() || !read_vunits(&x, 'v'))
     x = curenv->get_vertical_spacing();
+  if (x < V0) {
+    warning(WARN_RANGE, "ignoring request to save negative amount"
+                       " of vertical space: %1u", x.to_units());
+    skip_line();
+    return;
+  }
   if (curdiv->distance_to_next_trap() > x)
     curdiv->space(x, true /* forcing */);
   else

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

Reply via email to