gbranden pushed a commit to branch master
in repository groff.

commit c46ce10ede267c0bf2844b0ded15a1b968e3c460
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Sep 23 12:39:17 2026 -0500

    [grohtml]: Add null pointer checks.
    
    * src/preproc/html/pre-html.cpp (imageList::createImage): Add
      assert(3)ions and explicit null pointer checks (for `NDEBUG` builds)
      before dereferencing `i` pointer-to-structure and its `imageName`
      pointer-to-`char` member.
---
 ChangeLog                     |  7 +++++++
 src/preproc/html/pre-html.cpp | 12 ++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 8d4798351..4ed59937e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-09-23  G. Branden Robinson <[email protected]>
+
+       * src/preproc/html/pre-html.cpp (imageList::createImage): Add
+       assert(3)ions and explicit null pointer checks (for `NDEBUG`
+       builds) before dereferencing `i` pointer-to-structure and its
+       `imageName` pointer-to-`char` member.
+
 2026-09-24  G. Branden Robinson <[email protected]>
 
        [mdoc]: Import groff man(7)'s "you forgot to run tbl"
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 7b6993db2..fdb861356 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1035,6 +1035,12 @@ int imageList::getMaxX(int pageno)
 
 void imageList::createImage(imageItem *i)
 {
+  assert(i != 0 /* nullptr */);
+  if (0 /* nullptr */ == i->imageName) { // NDEBUG
+    fprintf(stderr, "%s: error: unable to generate raster image",
+           program_name);
+    fflush(stderr);
+  }
   if (i->X1 != -1) {
     int x1 = max(min(i->X1, i->X2) * image_res / postscriptRes
                   - IMAGE_BORDER_PIXELS,
@@ -1049,6 +1055,12 @@ void imageList::createImage(imageItem *i)
             + max(i->Y1, i->Y2) * image_res / postscriptRes
             + 1 + IMAGE_BORDER_PIXELS;
     if (createPage(i->pageNo) == 0) {
+      assert(i->imageName != 0 /* nullptr */);
+      if (0 /* nullptr */ == i->imageName) { // NDEBUG
+       fprintf(stderr, "%s: error: unable to generate raster image"
+               " of page %d\n", program_name, i->pageNo);
+       fflush(stderr);
+      }
       const char *s = make_string("pamcut%s %d %d %d %d < %s "
                                  "| pnmcrop%s " PNMTOOLS_QUIET
                                  "| pnmtopng%s " PNMTOOLS_QUIET " %s"

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

Reply via email to