File ImageMagick-CVE-2025-55004.patch of Package ImageMagick.40075

From 55d97055e00a7bc7ae2776c99824002fbb4a72aa Mon Sep 17 00:00:00 2001
From: Cristy <urban-warrior@imagemagick.org>
Date: Thu, 7 Aug 2025 19:14:00 -0400
Subject: [PATCH] 
 https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-cjc8-g9w8-chfw

---
 coders/png.c | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)

Index: ImageMagick-7.1.0-9/coders/png.c
===================================================================
--- ImageMagick-7.1.0-9.orig/coders/png.c
+++ ImageMagick-7.1.0-9/coders/png.c
@@ -5126,14 +5126,15 @@ static Image *ReadOneJNGImage(MngInfo *m
       jng_image=ReadImage(alpha_image_info,exception);
 
       if (jng_image != (Image *) NULL)
-        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception);
-          q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
-          if ((s == (const Quantum *)  NULL) || (q == (Quantum *) NULL))
-            break;
+          image->alpha_trait=BlendPixelTrait;
+          for (y=0; y < (ssize_t) image->rows; y++)
+          {
+            s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception);
+            q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
+            if ((s == (const Quantum *)  NULL) || (q == (Quantum *) NULL))
+              break;
 
-          if (image->alpha_trait != UndefinedPixelTrait)
             for (x=(ssize_t) image->columns; x != 0; x--)
             {
               SetPixelAlpha(image,GetPixelRed(jng_image,s),q);
@@ -5141,18 +5142,9 @@ static Image *ReadOneJNGImage(MngInfo *m
               s+=GetPixelChannels(jng_image);
             }
 
-          else
-            for (x=(ssize_t) image->columns; x != 0; x--)
-            {
-              SetPixelAlpha(image,GetPixelRed(jng_image,s),q);
-              if (GetPixelAlpha(image,q) != OpaqueAlpha)
-                image->alpha_trait=BlendPixelTrait;
-              q+=GetPixelChannels(image);
-              s+=GetPixelChannels(jng_image);
-            }
-
-          if (SyncAuthenticPixels(image,exception) == MagickFalse)
-            break;
+            if (SyncAuthenticPixels(image,exception) == MagickFalse)
+              break;
+          }
         }
       (void) RelinquishUniqueFileResource(alpha_image->filename);
       alpha_image=DestroyImageList(alpha_image);
openSUSE Build Service is sponsored by