gbranden pushed a commit to branch master
in repository groff.
commit 5eaefed881c88c4d60701cdcd39ca47a98abcf33
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jul 23 19:58:38 2026 -0500
src/roff/troff/div.cpp: Add assert(3)ion.
* src/roff/troff/div.cpp (write_any_trailer_and_exit): Add assert(3)ion
that `topdiv` is not a null pointer; in other words, that the
top-level diversion exists, which it must.
---
ChangeLog | 6 ++++++
src/roff/troff/div.cpp | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 2be612a55..0abcaf9b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-07-23 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/div.cpp (write_any_trailer_and_exit): Add
+ assert(3)ion that `topdiv` is not a null pointer; in other
+ words, that the top-level diversion exists, which it must.
+
2026-07-22 G. Branden Robinson <[email protected]>
* src/include/color.h: Drop unused private member variable
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 3ec7d13a4..46f970dd0 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -656,9 +656,11 @@ void end_diversions()
// input.cpp:exit_troff() cleans up most formatter state.
void write_any_trailer_and_exit(int exit_code)
{
+ assert(topdiv != 0 /* nullptr */);
// If output was never initialized, there is no trailer to write.
if (the_output != 0 /* nullptr */) {
- the_output->trailer(topdiv->get_page_length());
+ if (topdiv != 0 /* nullptr */) // NDEBUG
+ the_output->trailer(topdiv->get_page_length());
// If we're already dying, don't call the_output's destructor. See
// node.cpp:real_output_file::~real_output_file().
if (!the_output->is_dying)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit