gbranden pushed a commit to branch master
in repository groff.
commit 83e83786d9e5b53a502c1e34076ba64317399b92
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 17 10:42:49 2026 -0500
[troff]: Add error handling.
...to `file_iterator` constructor.
* src/roff/troff/input.cpp (file_iterator::file_iterator): Handle
invalid constructor arguments. Make assert(3)ion that the pointers
`f` (a `FILE`) or `fn` (a C string) are not null. In `NDEBUG` builds,
return early if either one is.
---
ChangeLog | 9 +++++++++
src/roff/troff/input.cpp | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4f1a518f9..de0baff7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-10-17 G. Branden Robinson <[email protected]>
+
+ [troff]: Add error handling to `file_iterator` constructor.
+
+ * src/roff/troff/input.cpp (file_iterator::file_iterator):
+ Handle invalid constructor arguments. Make assert(3)ion that
+ the pointers `f` (a `FILE`) or `fn` (a C string) are not null.
+ In `NDEBUG` builds, return early if either one is.
+
2026-10-16 G. Branden Robinson <[email protected]>
[troff]: Fix Savannah #68783.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index af673591e..0ed74edc9 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -469,6 +469,10 @@ file_iterator::file_iterator(FILE *f, const char *fn, bool
popened)
: fp(f), lineno(1), was_popened(popened),
seen_newline(false), seen_escape(false)
{
+ assert(f != 0 /* nullptr */);
+ assert(fn != 0 /* nullptr */);
+ if ((0 /* nullptr */ == f) || (0 /* nullptr */ == fn)) // NDEBUG
+ return;
filename = strdup(const_cast<char *>(fn));
if ((font::use_charnames_in_special) && (fn != 0 /* nullptr */)) {
if (!the_output)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit