Commit aa379c187 for imagemagick.org
commit aa379c1877b471bc20c89f1b2d55051a3c828977
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Dec 4 18:46:08 2026 -0500
ReadPlasmaImage now destroys the image and returns NULL when seeding fails
diff --git a/coders/plasma.c b/coders/plasma.c
index 793cf469e..4c0ce7687 100644
--- a/coders/plasma.c
+++ b/coders/plasma.c
@@ -146,6 +146,13 @@ static Image *ReadPlasmaImage(const ImageInfo *image_info,
/*
Recursively apply plasma to the image.
*/
+ assert(image_info != (const ImageInfo *) NULL);
+ assert(image_info->signature == MagickCoreSignature);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickCoreSignature);
+ if (IsEventLogging() != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+ image_info->filename);
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) FormatLocaleString(read_info->filename,MagickPathExtent,
@@ -203,13 +210,16 @@ static Image *ReadPlasmaImage(const ImageInfo *image_info,
segment_info.y2,exception);
random_info=DestroyRandomInfo(random_info);
if (status == MagickFalse)
- return(image);
+ return(DestroyImageList(image));
}
i=(size_t) MagickMax(image->columns,image->rows)/2;
for (max_depth=0; i != 0; max_depth++)
i>>=1;
- for (depth=1; ; depth++)
+ for (depth=1; depth <= (8*sizeof(size_t)); depth++)
{
+ /*
+ max_depth subdivisions suffice; the bound guards against a runaway loop.
+ */
if (PlasmaImage(image,&segment_info,0,depth,exception) != MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) depth,