gbranden pushed a commit to branch master
in repository groff.
commit 6e3e3c9707afe5ec8347f6ff22960bfed8866b80
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 24 19:02:20 2026 -0500
[libgroff]: Initialize memory more fastidiously.
* src/libs/libgroff/json_encode.cpp (json_encode_char): Explicitly
initialize stack-allocated structure. Fixes `-Wmaybe-uninitialized`
warning.
When designing the `json_char` `struct`, I forgot that each member of a
structure in C/C++ needs to be aligned, so my attempt to manually pack
the struct into 8 bytes was unavailing--a compiler can add padding
between the `len` and `buf` members.
---
ChangeLog | 6 ++++++
src/libs/libgroff/json_encode.cpp | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 8cfa1318b..b9795969f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-06-24 G. Branden Robinson <[email protected]>
+
+ * src/libs/libgroff/json_encode.cpp (json_encode_char):
+ Explicitly initialize stack-allocated structure. Fixes
+ `-Wmaybe-uninitialized` warning.
+
2026-06-20 G. Branden Robinson <[email protected]>
* doc/gpl.texi: Add copy of the GNU GPL in Texinfo format.
diff --git a/src/libs/libgroff/json_encode.cpp
b/src/libs/libgroff/json_encode.cpp
index 40960653b..7ff7763b1 100644
--- a/src/libs/libgroff/json_encode.cpp
+++ b/src/libs/libgroff/json_encode.cpp
@@ -27,7 +27,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
// Return JSON representation of character `c` without bracketing `"`s.
json_char json_encode_char(unsigned char c)
{
- json_char jc;
+ json_char jc = { 0, "" }; // C++11: jc{};
// These printable characters require escaping.
if (('"' == c) || ('\\' == c) || ('/' == c)) {
jc.len = 2;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit