gbranden pushed a commit to branch master
in repository groff.
commit e4ff2d4fcfd8e2fac1df204db9ee088081d5f432
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Dec 17 16:26:10 2025 -0600
src/roff/troff/input.cpp: Add paranoia.
* src/roff/troff/input.cpp (token::is_usable_as_delimiter): Explicitly
clear stack-allocated buffer before otherwise writing to it, for
paranoia's sake.
Also annotate how a C++03 feature would take care of that for us.
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 3 +++
2 files changed, 9 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index a455c5a39..f7170e7ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-12-17 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (token::is_usable_as_delimiter):
+ Explicitly clear stack-allocated buffer before otherwise writing
+ to it, for paranoia's sake.
+
2025-12-17 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Fix code style nits.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 00d3ca841..17cf93c5e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2928,7 +2928,9 @@ bool token::is_usable_as_delimiter(bool report_error,
const size_t maxstr
= sizeof "space character horizontal motion node token";
const size_t bufsz = maxstr + 1; // for trailing '\0'
+ // C++03: char[bufsz]();
static char buf[bufsz];
+ (void) memset(buf, 0, bufsz);
describe_node(buf, bufsz);
error("%1 is not allowed as a delimiter", buf);
}
@@ -2959,6 +2961,7 @@ const char *token::description()
const size_t maxstr
= sizeof "space character horizontal motion node token";
const size_t bufsz = maxstr + 2; // for trailing '"' and '\0'
+ // C++03: char[bufsz]();
static char buf[bufsz];
(void) memset(buf, 0, bufsz);
switch (type) {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit