gbranden pushed a commit to branch master
in repository groff.
commit cf347845afa6abb8042719bd91df9cb1483ed7be
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Apr 12 05:54:13 2026 -0500
src/roff/troff/env.cpp: Slightly refactor.
* src/roff/troff/env.cpp (print_hyphenation_exceptions): Declare `const`
symbol `bufsz` computed at compile time as `static`. Explicitly clear
the stack memory allocated to `wordbuf` array.
---
ChangeLog | 7 +++++++
src/roff/troff/env.cpp | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 810fa5189..c246fdb3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-04-12 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/env.cpp (print_hyphenation_exceptions):
+ Slightly refactor. Declare `const` symbol `bufsz` computed at
+ compile time as `static`. Explicitly clear the stack memory
+ allocated to `wordbuf` array.
+
2026-04-12 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp (read_hyphenation_exception_word):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index e01bdd48e..1868c5bd1 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -4104,8 +4104,11 @@ static void print_hyphenation_exceptions_request() //
.phw
// Pathologically, we could have a hyphenation point after every
// character in a word except the last. The word may have a trailing
// space; see `hyphen_trie::read_patterns_file()`.
- const size_t bufsz = WORD_MAX * 2;
- char wordbuf[bufsz]; // need to `errprint()` it, so not `unsigned`
+ // C++11: constexp
+ static const size_t bufsz = WORD_MAX * 2;
+ // C++03: char wordbuf[bufsz]();
+ char wordbuf[bufsz]; // We need to `errprint()` it, so not `unsigned`.
+ (void) memset(wordbuf, '\0', bufsz);
// We must use the nuclear `reinterpret_cast` operator because GNU
// troff's dictionary types use a pre-STL approach to containers.
while (iter.get(&entry, reinterpret_cast<void **>(&hypoint))) {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit