gbranden pushed a commit to branch master
in repository groff.

commit d7bda864bb581bdb96a40e53ca73cf2e81b71728
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jun 4 03:24:48 2026 -0500

    [grohtml]: Null-terminate `html_string`.
    
    * src/devices/grohtml/post-html.cpp (page::add_encode): Add null
      terminator to `html_string` groff `string`.  Its contents are shortly
      to become a C string.  Null-terminating it prevents trailing garbage
      from populating a `char_buffer`.
    
    This change prevents a forthcoming refactoring (to migrate from local
    `char_block` class to STL `std::vector<char>`) from spewing garbage into
    the output when formatting our document "webpage.ms" for HTML.
---
 ChangeLog                         | 7 +++++++
 src/devices/grohtml/post-html.cpp | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 90cfbdd0e..96b6bfb05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-06-04  G. Branden Robinson <[email protected]>
+
+       * src/devices/grohtml/post-html.cpp (page::add_encode): Add null
+       terminator to `html_string` groff `string`.  Its contents are
+       shortly to become a C string.  Null-terminating it prevents
+       trailing garbage from populating a `char_buffer`.
+
 2026-05-31  G. Branden Robinson <[email protected]>
 
        [grohtml]: Fix code style nit.
diff --git a/src/devices/grohtml/post-html.cpp 
b/src/devices/grohtml/post-html.cpp
index aa7213a5c..309aa68db 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -1593,7 +1593,8 @@ void page::add_and_encode (style *s,
       html_string += str[i];
     i++;
   }
-  if (html_string.length() > 0) {
+  html_string += '\0';
+  if (html_string.length() > 1 /* '\0' */) {
     text_glob *g=new text_glob();
     if (is_tag)
       g->text_glob_tag(s, buffer.add_string(html_string),

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

Reply via email to