Commit a63bdd29e for imagemagick.org

commit a63bdd29ebe8439d1bfa51ca4e7890b8b4742560
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Tue Sep 29 10:43:10 2026 -0400

    https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-8w9c-hj38-8pf9

diff --git a/coders/fpx.c b/coders/fpx.c
index 5de9190ca..a7e444862 100644
--- a/coders/fpx.c
+++ b/coders/fpx.c
@@ -773,6 +773,17 @@ static void SetSaturation(double saturation,FPXColorTwistMatrix *color_twist)
 static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
   ExceptionInfo *exception)
 {
+#define ThrowFPXException(severity,tag) \
+{ \
+  if (quantum_info != (QuantumInfo *) NULL) \
+    quantum_info=DestroyQuantumInfo(quantum_info); \
+  if (flashpix != (FPXImageHandle *) NULL) \
+    (void) FPX_CloseImage(flashpix); \
+  FPXRelinquishSummaryInfo(&summary_info); \
+  FPX_ClearSystem(); \
+  ThrowWriterException(severity,tag); \
+}
+
   FPXBackground
     background_color;

@@ -803,19 +814,19 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
     fpx_info;

   FPXImageHandle
-    *flashpix;
+    *flashpix = (FPXImageHandle *) NULL;

   FPXStatus
     fpx_status;

   FPXSummaryInformation
-    summary_info;
+    summary_info = { 0 };

   MagickBooleanType
     status;

   QuantumInfo
-    *quantum_info;
+    *quantum_info = (QuantumInfo *) NULL;

   QuantumType
     quantum_type;
@@ -861,7 +872,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
   memory_limit=20000000;
   fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit);
   if (fpx_status != FPX_OK)
-    ThrowWriterException(DelegateError,"UnableToInitializeFPXLibrary");
+    ThrowFPXException(DelegateError,"UnableToInitializeFPXLibrary");
   tile_width=64;
   tile_height=64;
   colorspace.numberOfComponents=3;
@@ -895,7 +906,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
       fpx_status=FPX_SetJPEGCompression(flashpix,(unsigned short)
         image->quality == UndefinedCompressionQuality ? 75 : image->quality);
       if (fpx_status != FPX_OK)
-        ThrowWriterException(DelegateError,"UnableToSetJPEGLevel");
+        ThrowFPXException(DelegateError,"UnableToSetJPEGLevel");
     }
   /*
     Set image summary info.
@@ -914,7 +925,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
         summary_info.title.ptr=(unsigned char *) AcquireQuantumMemory(
           length+MagickPathExtent,sizeof(*summary_info.title.ptr));
       if (summary_info.title.ptr == (unsigned char *) NULL)
-        ThrowWriterException(DelegateError,"UnableToSetImageTitle");
+        ThrowFPXException(DelegateError,"UnableToSetImageTitle");
       (void) CopyMagickString((char *) summary_info.title.ptr,label,
         MagickPathExtent);
     }
@@ -930,13 +941,13 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
     }
   fpx_status=FPX_SetSummaryInformation(flashpix,&summary_info);
   if (fpx_status != FPX_OK)
-    ThrowWriterException(DelegateError,"UnableToSetSummaryInfo");
+    ThrowFPXException(DelegateError,"UnableToSetSummaryInfo");
   /*
     Initialize FlashPix image description.
   */
   quantum_info=AcquireQuantumInfo(image_info,image);
   if (quantum_info == (QuantumInfo *) NULL)
-    ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+    ThrowFPXException(ResourceLimitError,"MemoryAllocationFailed");
   pixels=(unsigned char *) GetQuantumPixels(quantum_info);
   fpx_info.numberOfComponents=(unsigned int) colorspace.numberOfComponents;
   for (i=0; i < (ssize_t) fpx_info.numberOfComponents; i++)
@@ -1069,37 +1080,37 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
         {
           fpx_status=FPX_SetImageAffineMatrix(flashpix,&affine);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetAffineMatrix");
+            ThrowFPXException(DelegateError,"UnableToSetAffineMatrix");
         }
       if (aspect_ratio_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageResultAspectRatio(flashpix,&aspect_ratio);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetAspectRatio");
+            ThrowFPXException(DelegateError,"UnableToSetAspectRatio");
         }
       if (color_twist_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageColorTwistMatrix(flashpix,&color_twist);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetColorTwist");
+            ThrowFPXException(DelegateError,"UnableToSetColorTwist");
         }
       if (contrast_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageContrastAdjustment(flashpix,&contrast);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetContrast");
+            ThrowFPXException(DelegateError,"UnableToSetContrast");
         }
       if (sharpen_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageFilteringValue(flashpix,&sharpen);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetFilteringValue");
+            ThrowFPXException(DelegateError,"UnableToSetFilteringValue");
         }
       if (view_rect_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageROI(flashpix,&view_rect);
           if (fpx_status != FPX_OK)
-            ThrowWriterException(DelegateError,"UnableToSetRegionOfInterest");
+            ThrowFPXException(DelegateError,"UnableToSetRegionOfInterest");
         }
     }
   (void) FPX_CloseImage(flashpix);