Commit c4b3c9039 for imagemagick.org

commit c4b3c9039a1509e3e7869331773865b521a62f93
Author: Dirk Lemstra <dirk@lemstra.org>
Date:   Sat Aug 29 12:45:35 2026 +0200

    Added missing null check to avoid a null pointer dereference (GHSA-92rw-c5mw-27v4)

diff --git a/coders/pnm.c b/coders/pnm.c
index 312b8f93b..0cfcbfdde 100644
--- a/coders/pnm.c
+++ b/coders/pnm.c
@@ -161,6 +161,8 @@ static int PNMComment(Image *image,CommentInfo *comment_info)
   /*
     Read comment.
   */
+  if (comment_info->comment == (char *) NULL)
+    return(-1);
   p=comment_info->comment+strlen(comment_info->comment);
   for (c='#'; (c != EOF) && (c != (int) '\n') && (c != (int) '\r'); p++)
   {
@@ -1604,9 +1606,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       default:
         ThrowPNMException(CorruptImageError,"ImproperImageHeader");
     }
-    if (*comment_info.comment != '\0')
-      (void) SetImageProperty(image,"comment",comment_info.comment,exception);
-    comment_info.comment=DestroyString(comment_info.comment);
+    if (comment_info.comment != (char*)NULL)
+      {
+        if (*comment_info.comment != '\0')
+          (void) SetImageProperty(image,"comment",comment_info.comment,exception);
+        comment_info.comment=DestroyString(comment_info.comment);
+      }
     if (y < (ssize_t) image->rows)
       ThrowPNMException(CorruptImageError,"UnableToReadImageData");
     /*