Commit f7496a375 for imagemagick.org
commit f7496a3751205e8d1765da9d4922a6d51377dec9
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Sat Apr 18 14:28:49 2026 +0200
Call CloseBlob on the correct image to prevent the blob from remaining open (dlemstra/Magick.NET/issues/1997)
diff --git a/coders/png.c b/coders/png.c
index 8dc65e373..b8abe9c8c 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -8028,12 +8028,8 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
matte,
ping_exclude_iCCP,
- ping_exclude_zCCP;
+ ping_exclude_zCCP,
- volatile MagickBooleanType
- ping_have_blob;
-
- MagickBooleanType
ping_have_cheap_transparency,
ping_have_color,
ping_have_non_bw,
@@ -8052,6 +8048,9 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
tried_333,
tried_444;
+ volatile MagickBooleanType
+ ping_have_blob;
+
MemoryInfo
*volatile pixel_info;
@@ -9433,10 +9432,12 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
if (quantum_info != (QuantumInfo *) NULL)
quantum_info=DestroyQuantumInfo(quantum_info);
- if (ping_have_blob != MagickFalse)
- (void) CloseBlob(image);
image_info=DestroyImageInfo(image_info);
image=DestroyImage(image);
+
+ if (ping_have_blob != MagickFalse)
+ (void) CloseBlob(IMimage);
+
return(MagickFalse);
}
@@ -11386,12 +11387,12 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
pixel_info=RelinquishVirtualMemory(pixel_info);
- if (ping_have_blob != MagickFalse)
- (void) CloseBlob(image);
-
image_info=DestroyImageInfo(image_info);
image=DestroyImage(image);
+ if (ping_have_blob != MagickFalse)
+ (void) CloseBlob(IMimage);
+
/* Store bit depth actually written */
s[0]=(char) ping_bit_depth;
s[1]='\0';