gbranden pushed a commit to branch master
in repository groff.
commit 40dd5cd0587a4238f150490fdcdc794d947ede2c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Mar 15 23:03:52 2025 -0500
[troff]: Fix SEGV risk in previous commit.
* src/roff/troff/input.cpp (macro:json_dump): A `macro` object is not
guaranteed to contain a `macro_header`; check for a null pointer and
report an empty JSON string if there's no header.
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 5 ++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 89a975aae..cdf7d6500 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-03-15 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (macro:json_dump): A `macro` object
+ is not guaranteed to contain a `macro_header`; check for a null
+ pointer and report an empty JSON string if there's no header.
+
2025-03-15 G. Branden Robinson <[email protected]>
[troff]: Implement dumping of device extension node contents.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 9c4427f3f..71eec4fc8 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3716,7 +3716,10 @@ void macro::print_size()
void macro::json_dump()
{
- p->json_dump();
+ if (p != 0 /* nullptr */)
+ p->json_dump();
+ else
+ fputs("\"\"", stderr);
}
// make a copy of the first n bytes
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit