GraphicsMagick: FPX improvements. HRZ improvements. CSS stylesh...

GraphicsMagick Commits <[email protected]> Wed, 07 Aug 2024 17:04:27 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.10530.1723068282.7833.graphicsmagick-commit@lists.sourceforge.net>
changeset 8a5bcec62c1f in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=8a5bcec62c1f
summary: FPX improvements. HRZ improvements.  CSS stylesheet improvements. Re-generate all HTML.

diffstat:

 ChangeLog                              |    24 +-
 VisualMagick/installer/inc/version.isx |     4 +-
 coders/fpx.c                           |   242 ++-
 coders/hrz.c                           |   153 +-
 cscope.files                           |     1 -
 magick/version.h                       |     4 +-
 tests/rwfile.tap                       |     6 +-
 www/ChangeLog-2001.html                |     6 +-
 www/ChangeLog-2002.html                |     6 +-
 www/ChangeLog-2003.html                |     6 +-
 www/ChangeLog-2004.html                |     6 +-
 www/ChangeLog-2005.html                |     6 +-
 www/ChangeLog-2006.html                |     6 +-
 www/ChangeLog-2007.html                |     6 +-
 www/ChangeLog-2008.html                |     6 +-
 www/ChangeLog-2009.html                |     6 +-
 www/ChangeLog-2010.html                |     6 +-
 www/ChangeLog-2011.html                |     6 +-
 www/ChangeLog-2012.html                |     6 +-
 www/ChangeLog-2013.html                |     6 +-
 www/ChangeLog-2014.html                |     6 +-
 www/ChangeLog-2015.html                |     6 +-
 www/ChangeLog-2016.html                |     6 +-
 www/ChangeLog-2017.html                |     6 +-
 www/ChangeLog-2018.html                |     6 +-
 www/ChangeLog-2019.html                |     6 +-
 www/ChangeLog-2020.html                |     6 +-
 www/ChangeLog-2021.html                |     6 +-
 www/ChangeLog-2022.html                |     6 +-
 www/ChangeLog-2023.html                |     6 +-
 www/ChangeLog.html                     |    22 +-
 www/Changes.html                       |     6 +-
 www/Copyright.html                     |     6 +-
 www/FAQ.html                           |   142 +-
 www/Hg.html                            |    46 +-
 www/ImageMagickObject.html             |    18 +-
 www/Magick++/Blob.html                 |     6 +-
 www/Magick++/ChangeLog.html            |     9 +-
 www/Magick++/CoderInfo.html            |     6 +-
 www/Magick++/Color.html                |    42 +-
 www/Magick++/Drawable.html             |   322 +-
 www/Magick++/Enumerations.html         |   102 +-
 www/Magick++/Exception.html            |     6 +-
 www/Magick++/FormatCharacters.html     |     6 +-
 www/Magick++/Geometry.html             |    18 +-
 www/Magick++/Image.html                |   914 +++++-----
 www/Magick++/ImageDesign.html          |     6 +-
 www/Magick++/Montage.html              |    14 +-
 www/Magick++/PixelPacket.html          |     6 +-
 www/Magick++/Pixels.html               |     6 +-
 www/Magick++/TypeMetric.html           |     6 +-
 www/Magick++/index.html                |    30 +-
 www/OpenMP.html                        |    18 +-
 www/README.html                        |    26 +-
 www/api/animate.html                   |    30 +-
 www/api/annotate.html                  |    30 +-
 www/api/api.html                       |     6 +-
 www/api/attribute.html                 |    66 +-
 www/api/average.html                   |    18 +-
 www/api/cdl.html                       |    18 +-
 www/api/channel.html                   |    78 +-
 www/api/colormap.html                  |    42 +-
 www/api/compare.html                   |    90 +-
 www/api/composite.html                 |    18 +-
 www/api/confirm_access.html            |    30 +-
 www/api/constitute.html                |   102 +-
 www/api/decorate.html                  |    42 +-
 www/api/deprecate.html                 |   138 +-
 www/api/describe.html                  |    18 +-
 www/api/effect.html                    |   318 +-
 www/api/enhance.html                   |   102 +-
 www/api/error.html                     |   174 +-
 www/api/export.html                    |    42 +-
 www/api/fx.html                        |   138 +-
 www/api/hclut.html                     |    18 +-
 www/api/import.html                    |    42 +-
 www/api/list.html                      |   258 +-
 www/api/log.html                       |   150 +-
 www/api/magick.html                    |   198 +-
 www/api/memory.html                    |   114 +-
 www/api/monitor.html                   |    42 +-
 www/api/montage.html                   |    54 +-
 www/api/operator.html                  |    30 +-
 www/api/paint.html                     |    54 +-
 www/api/pixel_iterator.html            |   114 +-
 www/api/plasma.html                    |    18 +-
 www/api/profile.html                   |   102 +-
 www/api/registry.html                  |    54 +-
 www/api/render.html                    |    90 +-
 www/api/resize.html                    |    78 +-
 www/api/resource.html                  |    78 +-
 www/api/segment.html                   |    18 +-
 www/api/shear.html                     |    54 +-
 www/api/signature.html                 |    66 +-
 www/api/statistics.html                |    18 +-
 www/api/texture.html                   |    30 +-
 www/api/transform.html                 |   150 +-
 www/api/types.html                     |   242 +-
 www/api/widget.html                    |   162 +-
 www/authors.html                       |    18 +-
 www/benchmarks.html                    |    18 +-
 www/bugs.html                          |     6 +-
 www/docutils-api.css                   |    28 +-
 www/docutils-articles.css              |    36 +-
 www/download.html                      |    50 +-
 www/formats.html                       |     6 +-
 www/links.html                         |    62 +-
 www/miff.html                          |    14 +-
 www/mission.html                       |     6 +-
 www/motion-picture.html                |    86 +-
 www/perl.html                          |    66 +-
 www/process.html                       |    26 +-
 www/programming.html                   |     6 +-
 www/project.html                       |     6 +-
 www/quantize.html                      |    22 +-
 www/reference.html                     |     6 +-
 www/security.html                      |    22 +-
 www/thanks.html                        |    30 +-
 www/tools.html                         |    46 +-
 www/utilities.html                     |     6 +-
 www/wand/magick_wand.html              |  2854 ++++++++++++++++----------------
 www/wand/pixel_wand.html               |   522 ++--
 www/wand/wand.html                     |     6 +-
 123 files changed, 5129 insertions(+), 4908 deletions(-)

diffs (truncated from 22064 to 500 lines):

diff -r 28326839b4a9 -r 8a5bcec62c1f ChangeLog
--- a/ChangeLog	Sun Aug 04 18:00:52 2024 -0500
+++ b/ChangeLog	Wed Aug 07 17:02:19 2024 -0500
@@ -1,9 +1,27 @@
+2024-08-07  Bob Friesenhahn  <[email protected]>
+
+	* www/docutils-articles.css: reStructuredText style sheet
+	adjustments to work with HTML 4 and 5 synax, by Mark Mitchell.
+
+	* www/docutils-api.css: reStructuredText style sheet adjustments
+	for HTML 5, by Mark Mitchell.
+
+	* tests/rwfile.tap: Adjustments for FlashPIX tests.
+
+	* coders/fpx.c: Add tracing and attempt to reduce the amount of
+	memory which is leaked by the defective library.
+
+	* coders/hrz.c: Tidy and clarify code.
+
 2024-08-04  Bob Friesenhahn  <[email protected]>
 
 	* configure.ac, coders/dps.c: Display Postscript stopped being
-	available in Sun's Solaris in 2002 and has been gone from the
-	world for a long time already.  Remove support for Display
-	Postscript.
+	available after Sun Solaris 10 (if legacy Xsun was used rather
+	than Xorg) and has been substantially gone from the world for a
+	long time already since Oracle stopped supporting desktop systems
+	not long after acquiring Sun in 2010.  Remove support for Display
+	Postscript. Ghostscript works better since it supports multiple
+	pages whereas Display Postscript only supported one page.
 
 	* config/{config.guess,config.sub}: Re-bootstrap with latest
 	config.guess and config.sub.
diff -r 28326839b4a9 -r 8a5bcec62c1f VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sun Aug 04 18:00:52 2024 -0500
+++ b/VisualMagick/installer/inc/version.isx	Wed Aug 07 17:02:19 2024 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020240804"
-#define public MagickPackageReleaseDate "snapshot-20240804"
+#define public MagickPackageVersionAddendum ".020240807"
+#define public MagickPackageReleaseDate "snapshot-20240807"
diff -r 28326839b4a9 -r 8a5bcec62c1f coders/fpx.c
--- a/coders/fpx.c	Sun Aug 04 18:00:52 2024 -0500
+++ b/coders/fpx.c	Wed Aug 07 17:02:19 2024 -0500
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2022 GraphicsMagick Group
+% Copyright (C) 2003-2024 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -31,6 +31,17 @@
 %
 %
 */
+/*
+  Please note that the FlashPIX library is very old and contains many
+  bugs.  There are many memory leaks, some of which are not easily
+  fixed due to a defective API design.  FlashPIX is based on a Windows
+  OLE filesystem.  Recently it has been noticed (using the libfpx
+  provided by the ImageMagick Github project) that libfpx modifies
+  (re-writes) its input file, even though it was only intentionally
+  opened for read!  But if the permissions on the input file are
+  read-only then the input file is not modified and there is no
+  reported error.
+*/
 
 /*
   Include declarations.
@@ -58,6 +69,143 @@
 */
 static unsigned int
   WriteFPXImage(const ImageInfo *,Image *);
+
+/*
+  Macro to free allocated content in FPXSummaryInformation
+
+  Unfortunately, the expected memory allocation/deallocation model for
+  FPX_GetSummaryInformation() is not defined.  It acts as a memory leak.
+*/
+#define MagickReleaseSummaryInfo(summary_info)                          \
+  {                                                                     \
+    if (summary_info.title_valid)                                       \
+      (void) FPX_DeleteFPXStr(&summary_info.title);                     \
+    if (summary_info.subject_valid)                                     \
+      (void) FPX_DeleteFPXStr(&summary_info.subject);                   \
+    if (summary_info.author_valid)                                      \
+      (void) FPX_DeleteFPXStr(&summary_info.author);                    \
+    if (summary_info.keywords_valid)                                    \
+      (void) FPX_DeleteFPXStr(&summary_info.keywords);                  \
+    if (summary_info.comments_valid)                                    \
+      (void) FPX_DeleteFPXStr(&summary_info.comments);                  \
+    if (summary_info.OLEtemplate_valid)                                 \
+      (void) FPX_DeleteFPXStr(&summary_info.OLEtemplate);               \
+    if (summary_info.last_author_valid)                                 \
+      (void) FPX_DeleteFPXStr(&summary_info.last_author);               \
+    if (summary_info.rev_number_valid)                                  \
+      (void) FPX_DeleteFPXStr(&summary_info.rev_number);                \
+    if (summary_info.appname_valid)                                     \
+      (void) FPX_DeleteFPXStr(&summary_info.appname);                   \
+    if (summary_info.thumbnail_valid)                                   \
+      if (summary_info.thumbnail.pClipData)                             \
+        {                                                               \
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),           \
+                                "Not freeing pClipData!");              \
+        }                                                               \
+  }
+
+#define MagickLogSummaryInfo(summary_info)                              \
+  {                                                                     \
+    if (summary_info.title_valid)                                       \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Title: %*s",                               \
+                            (int)summary_info.title.length,             \
+                            (const char *)summary_info.title.ptr);      \
+    if (summary_info.subject_valid)                                     \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Subject: %*s",                             \
+                            (int)summary_info.subject.length,           \
+                            (const char *)summary_info.subject.ptr);    \
+    if (summary_info.author_valid)                                      \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Author: %*s",                              \
+                            (int)summary_info.author.length, \
+                            (const char *)summary_info.author.ptr);     \
+    if (summary_info.keywords_valid)                                    \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Keywords: %*s",                            \
+                            (int)summary_info.keywords.length, \
+                            (const char *)summary_info.keywords.ptr);   \
+    if (summary_info.comments_valid)                                    \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Comments: %*s",                            \
+                            (int)summary_info.comments.length,          \
+                            (const char *)summary_info.comments.ptr);   \
+    if (summary_info.OLEtemplate_valid)                                 \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "OLEtemplate: %*s",                         \
+                            (int)summary_info.OLEtemplate.length,       \
+                            (const char *)summary_info.OLEtemplate.ptr); \
+    if (summary_info.last_author_valid)                                 \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Last Author: %*s",                         \
+                            (int)summary_info.last_author.length,       \
+                            (const char *)summary_info.last_author.ptr); \
+    if (summary_info.rev_number_valid)                                  \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Revision Number: %*s",                     \
+                            (int)summary_info.rev_number.length,        \
+                            (const char *)summary_info.rev_number.ptr); \
+    if (summary_info.edit_time_valid)                                   \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Edit Time: %u,%u",                         \
+                            summary_info.edit_time.dwLowDateTime,       \
+                            summary_info.edit_time.dwHighDateTime);     \
+    if (summary_info.last_printed_valid)                                \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Last Printed Time: %u,%u",                 \
+                            summary_info.last_printed.dwLowDateTime,    \
+                            summary_info.last_printed.dwHighDateTime);  \
+    if (summary_info.create_dtm_valid)                                  \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Create DTM Time: %u,%u",                   \
+                            summary_info.create_dtm.dwLowDateTime,      \
+                            summary_info.create_dtm.dwHighDateTime);    \
+    if (summary_info.last_save_dtm_valid)                               \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Save DTM Time: %u,%u",                     \
+                            summary_info.last_save_dtm.dwLowDateTime,   \
+                            summary_info.last_save_dtm.dwHighDateTime); \
+    if (summary_info.page_count_valid)                                  \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Page Count: %u",                           \
+                            summary_info.page_count);                   \
+    if (summary_info.word_count_valid)                                  \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Word Count: %u",                           \
+                            summary_info.word_count);                   \
+    if (summary_info.char_count_valid)                                  \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Char Count: %u",                           \
+                            summary_info.char_count);                   \
+    if (summary_info.thumbnail_valid)                                   \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "ThumbNail: pClipData=%p",                  \
+                            summary_info.thumbnail.pClipData);          \
+    if (summary_info.appname_valid)                                     \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "App Name: %*s",                            \
+                            (int)summary_info.appname.length,           \
+                            (const char *)summary_info.appname.ptr);    \
+    if (summary_info.security_valid)                                    \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),               \
+                            "Security: 0x%04lx",                        \
+                            summary_info.security);                     \
+}
+
+#if 0
+/* There is some issue with thumbnail cbSize and ulClipFmt being uninitialized data! */
+    if (summary_info.thumbnail_valid)                               \
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),     \
+                            "ThumbNail: cbSize=%u, ulClipFmt=%d, pClipData=%p", summary_info.thumbnail.cbSize, summary_info.thumbnail.ulClipFmt, summary_info.thumbnail.pClipData);
+#endif
+
+/* typedef CLIPDATA  FPXThumbnail; Has allocated memory (uint8_t *) in pClipData
+   And data is actually returned!
+   Allocated by (CLIPDATA*)CoTaskMemAlloc(sizeof(CLIPDATA));
+   Freed by CoTaskMemFree()
+*/
+
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -191,6 +339,7 @@
   size_t
     memory_limit;
 
+
   /*
     Open image.
   */
@@ -199,6 +348,7 @@
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
+
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
@@ -207,6 +357,7 @@
   /*
     Initialize FPX toolkit.
   */
+  (void) memset(&summary_info,0,sizeof(summary_info));
   fpx_status=FPX_InitSystem();
   if (fpx_status != FPX_OK)
     {
@@ -219,6 +370,7 @@
       FPX_ClearSystem();
       ThrowReaderException(CoderError,UnableToInitializeFPXLibrary,image);
     }
+
   tile_width=64;
   tile_height=64;
   flashpix=(FPXImageHandle *) NULL;
@@ -254,53 +406,27 @@
   fpx_status=FPX_GetSummaryInformation(flashpix,&summary_info);
   if (fpx_status != FPX_OK)
     {
+      MagickReleaseSummaryInfo(summary_info);
       FPX_ClearSystem();
       ThrowReaderException(CoderError,UnableToReadSummaryInfo,image);
-    }
+  }
+  MagickLogSummaryInfo(summary_info);
   if (summary_info.title_valid)
     if ((summary_info.title.length != 0) &&
         (summary_info.title.ptr != (unsigned char *) NULL))
       {
-        char
-          *label;
-
-        /*
-          Note image label.
-        */
-        label=MagickAllocateResourceLimitedMemory(char *,summary_info.title.length+1);
-        if (label == (char *) NULL)
-          {
-            FPX_ClearSystem();
-            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-              image);
-          }
-        (void) strlcpy(label,(char *) summary_info.title.ptr,
-          summary_info.title.length+1);
-        (void) SetImageAttribute(image,"label",label);
-        MagickFreeResourceLimitedMemory(label);
+        /* It is observed that the buffer is NUL terminated */
+        (void) SetImageAttribute(image,"label",(const char *) summary_info.title.ptr);
       }
   if (summary_info.comments_valid)
     if ((summary_info.comments.length != 0) &&
         (summary_info.comments.ptr != (unsigned char *) NULL))
       {
-        char
-          *comments;
-
-        /*
-          Note image comment.
-        */
-        comments=MagickAllocateResourceLimitedMemory(char *,summary_info.comments.length+1);
-        if (comments == (char *) NULL)
-          {
-            FPX_ClearSystem();
-            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-              image);
-          }
-        (void) strlcpy(comments,(char *) summary_info.comments.ptr,
-          summary_info.comments.length+1);
-        (void) SetImageAttribute(image,"comment",comments);
-        MagickFreeResourceLimitedMemory(comments);
+        /* It is observed that the buffer is NUL terminated */
+        (void) SetImageAttribute(image,"comment",(const char *) summary_info.comments.ptr);
       }
+  /* FIXME: For some reason freeing memory here still leaks it! */
+  MagickReleaseSummaryInfo(summary_info);
   /*
     Determine resolution by subimage specification.
   */
@@ -450,7 +576,9 @@
     if (!SyncImagePixels(image))
       break;
     if (QuantumTick(y,image->rows))
-      if (!MagickMonitor(LoadImageText,y,image->rows,exception))
+      if (!MagickMonitorFormatted(y,image->rows,exception,
+                                  LoadImageText,image->filename,
+                                  image->columns,image->rows))
         break;
   }
   MagickFreeResourceLimitedMemory(scanline);
@@ -505,6 +633,7 @@
   entry->magick=(MagickHandler) IsFPX;
   entry->description="FlashPix Format";
   entry->module="FPX";
+  entry->coder_class=UnstableCoderClass;
   (void) RegisterMagickInfo(entry);
 }
 
@@ -807,12 +936,17 @@
   /*
     Initialize FPX toolkit.
   */
-  image->depth=8;
-  (void) TransformColorspace(image,RGBColorspace);
   memory_limit=20000000;
   fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit);
   if (fpx_status != FPX_OK)
     ThrowWriterException(DelegateError,UnableToInitializeFPXLibrary,image);
+  fpx_status=FPX_InitSystem();
+  if (fpx_status != FPX_OK)
+    ThrowWriterException(CoderError,UnableToInitializeFPXLibrary,image);
+
+  (void) memset(&summary_info,0,sizeof(summary_info));
+  image->depth=8;
+  (void) TransformColorspace(image,RGBColorspace);
   tile_width=64;
   tile_height=64;
   colorspace.numberOfComponents=3;
@@ -872,18 +1006,8 @@
   label=GetImageAttribute(image,"label");
   if (label != (ImageAttribute *) NULL)
     {
-      /*
-        Note image label.
-      */
-      summary_info.title_valid=True;
-      summary_info.title.length=strlen(label->value);
-      summary_info.title.ptr=MagickAllocateMemory(unsigned char *,
-        strlen(label->value)+1);
-      if (summary_info.title.ptr != (unsigned char *) NULL)
-        (void) strlcpy((char *) summary_info.title.ptr,label->value,
-          MaxTextExtent);
-      else
-        ThrowWriterException(CoderError,UnableToSetImageTitle,image);
+      InitFPXStr(&summary_info.title);
+      summary_info.title_valid=(FPX_Strcpy(&summary_info.title, label->value) ==  FPX_OK);
     }
   comment=GetImageAttribute(image,"comment");
   if (comment != (ImageAttribute *) NULL)
@@ -891,16 +1015,12 @@
       /*
         Note image comment.
       */
-      summary_info.comments_valid=True;
-      summary_info.comments.length=strlen(comment->value);
-      summary_info.comments.ptr=MagickAllocateMemory(unsigned char *,
-        summary_info.comments.length+1);
-      if (summary_info.comments.ptr != (unsigned char *) NULL)
-        (void) strlcpy((char *) summary_info.comments.ptr,comment->value,summary_info.comments.length+1);
-      else
-        ThrowWriterException(CoderError,UnableToSetImageComments,image);
+      InitFPXStr(&summary_info.comments);
+      summary_info.comments_valid=(FPX_Strcpy(&summary_info.comments, comment->value) == FPX_OK);
     }
+  MagickLogSummaryInfo(summary_info);
   fpx_status=FPX_SetSummaryInformation(flashpix,&summary_info);
+  MagickReleaseSummaryInfo(summary_info);
   if (fpx_status != FPX_OK)
     ThrowWriterException(CoderError,UnableToSetSummaryInfo,image);
   /*
@@ -951,7 +1071,9 @@
     if (fpx_status != FPX_OK)
       break;
     if (QuantumTick(y,image->rows))
-      if (!MagickMonitor(SaveImageText,y,image->rows,&image->exception))
+      if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                  LoadImageText,image->filename,
+                                  image->columns,image->rows))
         break;
   }
   if (image_info->view != (char *) NULL)
diff -r 28326839b4a9 -r 8a5bcec62c1f coders/hrz.c
--- a/coders/hrz.c	Sun Aug 04 18:00:52 2024 -0500
+++ b/coders/hrz.c	Wed Aug 07 17:02:19 2024 -0500
@@ -53,7 +53,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Method ReadHRZImage reads an HRZ X image file and returns it.  It
+%  Method ReadHRZImage reads an HRZ image file and returns it.  It
 %  allocates the memory necessary for the new Image structure and returns a
 %  pointer to the new image.
 %
@@ -76,12 +76,11 @@
 static Image *ReadHRZImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image *image;
-  int i;
-  unsigned width,height;
-  long ldblk, j;
-  unsigned char *BImgBuff=NULL;
+  unsigned char *BImgBuff;
+  const PixelPacket *q;
+  size_t ldblk;
+  unsigned long x,y,width,height;
   unsigned int status;
-  const PixelPacket *q;
 
   /*
     Open image file.
@@ -101,14 +100,13 @@
   */
   width = 256;
   height = 240;
-
-  ldblk = (long)(3*width);
+  ldblk = 3*width;
 
-  if(BlobIsSeekable(image))
-  {
-    if(GetBlobSize(image)!=((magick_off_t) ((size_t)ldblk*height)))
-      ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-  }
+  if (BlobIsSeekable(image))
+    {
+      if (GetBlobSize(image) != ((magick_off_t) ((size_t)ldblk*height)))
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+    }
 
   image->columns = width;
   image->rows = height;
@@ -116,35 +114,40 @@
 
   /* printf("HRZ header checked OK %d,%d\n",image->colors,image->depth); */
 
-  /* If ping is true, then only set image size and colors without reading any image data. */
-  if (image_info->ping) goto DONE_READING;
+  /* If ping is true, then only set image size without reading any image data. */
+  if (image_info->ping)
+    goto DONE_READING;
 
-  /* ----- Load RLE compressed raster ----- */
-  BImgBuff=MagickAllocateResourceLimitedMemory(unsigned char *,((size_t) ldblk));  /*Ldblk was set in the check phase*/
-  if(BImgBuff==NULL)
+  /* ----- Load packed raster ----- */
+  BImgBuff=MagickAllocateResourceLimitedMemory(unsigned char *, ldblk);
+  if (BImgBuff==NULL)
     ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
-  for(i=0; i<(int)height; i++)
+  for (y=0; y < height; y++)
     {
-      (void) ReadBlob(image,(size_t)ldblk,(char *)BImgBuff);
+      if (ReadBlob(image,ldblk,(char *)BImgBuff) != ldblk)
+        break;
 
-      for(j=0; j<ldblk; j++)
-      {
-        BImgBuff[j] <<= 2;
-      }
+      for (x=0; x < ldblk; x++)
+        {
+          BImgBuff[x] <<= 2;
+        }
 
-      q = SetImagePixels(image,0,i,image->columns,1);
-      if(q == (PixelPacket *)NULL) break;
-      (void)ImportImagePixelArea(image,RGBQuantum,8,BImgBuff,NULL,0);
-      if(!SyncImagePixels(image)) break;
+      q = SetImagePixels(image,0,y,image->columns,1);
+      if (q == (PixelPacket *)NULL)
+        break;
+
+      (void) ImportImagePixelArea(image,RGBQuantum,8,BImgBuff,NULL,0);
+      if (!SyncImagePixels(image))
+        break;
     }