groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: [pre-grohtml]: Fix post-1.23.0 infloop regression.


From: G. Branden Robinson
Subject: [groff] 01/01: [pre-grohtml]: Fix post-1.23.0 infloop regression.
Date: Wed, 12 Jul 2023 22:13:02 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 3113c2d36bbcf11509f065887f33a538f7259887
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jul 12 20:17:03 2023 -0500

    [pre-grohtml]: Fix post-1.23.0 infloop regression.
    
    * src/preproc/html/pushback.cpp (pushBackBuffer::isString): Partially
      revert commit 411b42f4ec, 2 June.  This member function needs a signed
      type to iterate backwards for internal validation purposes, so use
      `ptrdiff_t` instead of `size_t`.  Fixes post-1.23.0 problem with
      pre-grohtml infinitely looping on complex documents like
      groff_char(7).  Mea culpa.
---
 ChangeLog                     |  9 +++++++++
 src/preproc/html/pushback.cpp | 11 +++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0bfc0626c..6bfee5906 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-07-12  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/html/pushback.cpp (pushBackBuffer::isString):
+       Partially revert commit 411b42f4ec, 2 June.  This member
+       function needs a signed type to iterate backwards for internal
+       validation purposes, so use `ptrdiff_t` instead of `size_t`.
+       Fixes post-1.23.0 problem with pre-grohtml infinitely looping on
+       complex documents like groff_char(7).  Mea culpa.
+
 2023-06-26  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [eqn]: Clarify diagnostic message.
diff --git a/src/preproc/html/pushback.cpp b/src/preproc/html/pushback.cpp
index f1172ef5b..eee746ba7 100644
--- a/src/preproc/html/pushback.cpp
+++ b/src/preproc/html/pushback.cpp
@@ -190,8 +190,8 @@ void pushBackBuffer::skipUntilToken (void)
 
 int pushBackBuffer::isString (const char *s)
 {
-  size_t length=strlen(s);
-  size_t i=0;
+  ptrdiff_t length=ptrdiff_t(strlen(s));
+  ptrdiff_t i=0;
 
   while ((i<length) && (putPB(getPB())==s[i])) {
     if (getPB() != s[i]) {
@@ -203,8 +203,11 @@ int pushBackBuffer::isString (const char *s)
     return( TRUE );
   } else {
     i--;
-    if (putPB(s[i]) != s[i]) {
-      ERROR("assert failed");
+    while (i>=0) {
+      if (putPB(s[i]) != s[i]) {
+       ERROR("assert failed");
+      }
+      i--;
     }
   }
   return( FALSE );



reply via email to

[Prev in Thread] Current Thread [Next in Thread]