groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/23: src/roff/troff/input.cpp: Fix Savannah #62813.


From: G. Branden Robinson
Subject: [groff] 05/23: src/roff/troff/input.cpp: Fix Savannah #62813.
Date: Sat, 30 Jul 2022 14:53:43 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 812604ac60537acdbe714270eaaafb21170fe10c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jul 25 15:28:24 2022 -0500

    src/roff/troff/input.cpp: Fix Savannah #62813.
    
    * src/roff/troff/input.cpp (input_char_description): Clear static buffer
      on every entry to the function so that calling it twice in succession
      where the second call populates the buffer with less data doesn't
      return leftover garbage characters.  Problem appears to date back to
      1991 or earlier.
    
    Fixes <https://savannah.gnu.org/bugs/?62813>.
---
 ChangeLog                | 10 ++++++++++
 src/roff/troff/input.cpp |  5 ++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 5355a4d41..9c86e6c40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,16 @@
        greek characters only slant if the glyp is sourced from a
        special font, not if the regular font contains greek glyphs.
 
+2022-07-25  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp (input_char_description): Clear
+       static buffer on every entry to the function so that calling it
+       twice in succession where the second call populates the buffer
+       with less data doesn't return leftover garbage characters.
+       Problem appears to date back to 1991 or earlier.
+
+       Fixes <https://savannah.gnu.org/bugs/?62813>.
+
 2022-07-25  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (token::usable_as_delimiter):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f47c86981..2dfe3efac 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6651,7 +6651,10 @@ const char *input_char_description(int c)
   case '\0':
     return "node";
   }
-  static char buf[sizeof("magic character code ") + 1 + INT_DIGITS];
+  size_t bufsz = sizeof "magic character code "  + INT_DIGITS + 1;
+  // repeat expression; no VLAs in ISO C++
+  static char buf[sizeof "magic character code "  + INT_DIGITS + 1];
+  (void) memset(buf, 0, bufsz);
   if (invalid_input_char(c)) {
     const char *s = asciify(c);
     if (*s) {



reply via email to

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