gbranden pushed a commit to branch master
in repository groff.

commit 27147bcb54c828fc5e79de77ca62e68637424d2f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 31 22:03:53 2026 -0500

    [grohtml]: Add paranoia. (1/2)
    
    * src/devices/grohtml/post-html.cpp (generate_img_src): Ensure we don't
      dereference a null `filename` pointer.  (Strictly, the `static`
      function `exists()` handles that case for us, but my idea of
      design-by-contract permits sanity checks on both ends of a call.  This
      choice also gives us flexibility to replace or change `exists()`,
      possibly with a standard library function call.)
---
 ChangeLog                         | 10 ++++++++++
 src/devices/grohtml/post-html.cpp |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e5a114d8d..fe10d252e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-05-31  G. Branden Robinson <[email protected]>
+
+       * src/devices/grohtml/post-html.cpp (generate_img_src): Add
+       paranoia.  Ensure we don't dereference a null `filename`
+       pointer.  (Strictly, the `static` function `exists()` handles
+       that case for us, but my idea of design-by-contract permits
+       sanity checks on both ends of a call.  This choice also gives us
+       flexibility to replace or change `exists()`, possibly with a
+       standard library function call.)
+
 2026-05-31  G. Branden Robinson <[email protected]>
 
        * src/devices/grohtml/post-html.cpp: Fix code style nit.
diff --git a/src/devices/grohtml/post-html.cpp 
b/src/devices/grohtml/post-html.cpp
index ec721f5c5..3f43252ad 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -2614,7 +2614,7 @@ static string &generate_img_src (const char *filename)
 
   while ((filename != 0 /* nullptr */) && (' ' == filename[0]))
     filename++;
-  if (exists(filename)) {
+  if ((0 /* nullptr */ == filename) || exists(filename)) {
     *s += string("<img src=\"") + filename + "\" "
          + "alt=\"Image " + filename + "\">";
     if (xhtml == dialect)

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to