gbranden pushed a commit to branch master
in repository groff.
commit c50876a7e7878dc5ce14397e5aca87495a210e9c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 20 21:12:29 2026 -0600
[grotty]: Add null pointer check.
* src/devices/grotty/tty.cpp (tty_printer::add_char): Add null pointer
check. In principle, we could make `pp`'s non-nullity an assert(3)ion
instead, as it should be invariant, but doing so would require
rewriting the `for` loop, as `pp` is updated as part of what the ISO C
standard calls "expression-3", the one that runs after each execution
of the loop body.
---
ChangeLog | 9 +++++++++
src/devices/grotty/tty.cpp | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 7acadc26c..a8d0bfdaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-11-20 G. Branden Robinson <[email protected]>
+
+ * src/devices/grotty/tty.cpp (tty_printer::add_char): Add null
+ pointer check. In principle, we could make `pp`'s non-nullity
+ an assert(3)ion instead, as it should be invariant, but doing so
+ would require rewriting the `for` loop, as `pp` is updated as
+ part of what the ISO C standard calls "expression-3", the one
+ that runs after each execution of the loop body.
+
2026-11-20 G. Branden Robinson <[email protected]>
* src/devices/grotty/tty.cpp (tty_printer::add_char): When
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 81b0bd3c8..df98d72c2 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -475,7 +475,7 @@ void tty_printer::add_char(output_character c, int w,
tty_glyph **pp;
for (pp = lines + (vpos - 1);
- *pp != 0 /* nullptr */;
+ (pp != 0 /* nullptr */) && (*pp != 0 /* nullptr */);
pp = &(*pp)->next)
if ((*pp)->hpos < hpos
|| ((*pp)->hpos == hpos && (*pp)->order() >= g->order()))
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit