gbranden pushed a commit to branch master
in repository groff.

commit 2881122ae4995621e52db6765d1099284fa109f8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 12:40:58 2026 -0600

    [grotty]: Improve fix for Savannah #68942.
    
    * src/devices/grotty/tty.cpp (tty_printer::add_char): Ensure that
      `new_nlines` can undergo integer wraparound at most once per trip
      through this function.
---
 ChangeLog                  | 6 ++++++
 src/devices/grotty/tty.cpp | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index bd8f6895e..2aeadf8d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-11-22  G. Branden Robinson <[email protected]>
+
+       * src/devices/grotty/tty.cpp (tty_printer::add_char): Improve
+       fix for Savannah #68942.  Ensure that `new_nlines` can undergo
+       integer wraparound at most once per trip through this function.
+
 2026-11-22  G. Branden Robinson <[email protected]>
 
        [soelim]: Add test exercising FSM states.
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 15133bc4c..15e7a3f2d 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -428,7 +428,7 @@ void tty_printer::add_char(output_character c, int w,
     // If we exceed the previous page length, double the size so that we
     // don't thrash the allocator.  See Savannah #68145.
     int new_nlines = nlines;
-    while (vpos > new_nlines)
+    while ((vpos > new_nlines) && (new_nlines > 0))
       new_nlines *= 2;
     if (new_nlines < 0)
       fatal("vertical motion to line %1 is too large", vpos);

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

Reply via email to