gbranden pushed a commit to branch master
in repository groff.
commit 4e131761b9420c11e65323f20482546bba4834d8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu May 28 15:48:08 2026 -0500
src/roff/troff/div.cpp: Add validation paranoia.
* src/roff/troff/div.cpp (top_level_diversion::add_trap)
(top_level_diversion::remove_trap)
(macro_diversion::set_diversion_trap): Add assert(3)ions and (if
`#define NDEBUG`) early returns if the `symbol` argument `is_null()`.
---
ChangeLog | 8 ++++++++
src/roff/troff/div.cpp | 9 +++++++++
2 files changed, 17 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 6e20be7a5..2941aaa11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-05-28 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/div.cpp (top_level_diversion::add_trap)
+ (top_level_diversion::remove_trap)
+ (macro_diversion::set_diversion_trap): Add assert(3)ions and
+ {if `#define NDEBUG`} early returns if the `symbol` argument
+ `is_null()`.
+
2026-05-28 G. Branden Robinson <[email protected]>
* src/roff/troff/div.cpp (when_request, diversion_trap_request):
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 32e8b2d29..487021830 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -576,6 +576,9 @@ trap::trap(symbol s, vunits n, trap *p)
void top_level_diversion::add_trap(symbol nam, vunits pos)
{
+ assert(!nam.is_null());
+ if (nam.is_null())
+ return;
trap *first_free_slot = 0 /* nullptr*/;
trap **p;
for (p = &page_trap_list; *p; p = &(*p)->next) {
@@ -598,6 +601,9 @@ void top_level_diversion::add_trap(symbol nam, vunits pos)
void top_level_diversion::remove_trap(symbol nam)
{
+ assert(!nam.is_null());
+ if (nam.is_null())
+ return;
for (trap *p = page_trap_list; p; p = p->next)
if (p->nm == nam) {
p->nm = NULL_SYMBOL;
@@ -973,6 +979,9 @@ static void flush_request() // .fl
void macro_diversion::set_diversion_trap(symbol s, vunits n)
{
+ assert(!s.is_null());
+ if (s.is_null())
+ return;
diversion_trap = s;
diversion_trap_pos = n;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit