gbranden pushed a commit to branch master
in repository groff.
commit 1f7113c8ad630600c1352fe114ace9b543c4ab25
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 3 17:38:00 2026 -0500
[troff]: Enhance dictionary iterator.
* src/roff/troff/dictionary.cpp (dictionary_iterator::get): Accept a
null pointer as second argument, to handle situation where the caller
is interested only in the dictionary's keys. Dereference the pointer
only if that argument is not null. (There was no check for this
previously; were I not making this change, I'd be assert(3)ing that
instead.)
---
ChangeLog | 9 +++++++++
src/roff/troff/dictionary.cpp | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 721895def..f38c4c385 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-03 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/dictionary.cpp (dictionary_iterator::get):
+ Accept a null pointer as second argument, to handle situation
+ where the caller is interested only in the dictionary's keys.
+ Dereference the pointer only if that argument is not null.
+ {There was no check for this previously; were I not making this
+ change, I'd be assert(3)ing that instead.}
+
2026-04-03 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Promote `process_input_stack()`'s
diff --git a/src/roff/troff/dictionary.cpp b/src/roff/troff/dictionary.cpp
index 4aebc1f92..34691aa74 100644
--- a/src/roff/troff/dictionary.cpp
+++ b/src/roff/troff/dictionary.cpp
@@ -134,7 +134,8 @@ bool dictionary_iterator::get(symbol *sp, void **vp)
for (; i < dict->size; i++)
if (dict->table[i].v) {
*sp = dict->table[i].s;
- *vp = dict->table[i].v;
+ if (vp != 0 /* nullptr */)
+ *vp = dict->table[i].v;
i++;
return true;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit